From: Joseph Spiros Date: Mon, 4 Apr 2005 21:28:31 +0000 (+0000) Subject: Initial import of ITMac sources. X-Git-Tag: v1.0~2 X-Git-Url: http://git.ithinksw.org/ITMac.git/commitdiff_plain/72c2f76c432c207c19a0b29836746d311ae7aa34 Initial import of ITMac sources. Source control of ITMac will now be handled by Subversion. --- 72c2f76c432c207c19a0b29836746d311ae7aa34 diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..22ef03a Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/ITAppleEventTools.h b/ITAppleEventTools.h new file mode 100644 index 0000000..e38301a --- /dev/null +++ b/ITAppleEventTools.h @@ -0,0 +1,22 @@ +/* + * ITMac + * ITAppleEventTools.h + * + * Functions to aid in sending raw AppleEvents. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import + +extern NSString *_ITAEDescCarbonDescription(AEDesc desc); + +extern NSAppleEventDescriptor *ITSendAE(FourCharCode eClass, FourCharCode eID, const ProcessSerialNumber *psn); +extern NSAppleEventDescriptor *ITSendAEWithKey(FourCharCode reqKey, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn); +extern NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn); +extern NSAppleEventDescriptor *ITSendAEWithStringAndObject(NSString *sendString, const AEDesc *object, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn); \ No newline at end of file diff --git a/ITAppleEventTools.m b/ITAppleEventTools.m new file mode 100644 index 0000000..81f858a --- /dev/null +++ b/ITAppleEventTools.m @@ -0,0 +1,126 @@ +#import "ITAppleEventTools.h" +#import + +NSString *_ITAEDescCarbonDescription(AEDesc desc) { + Handle descHandle; + NSString *carbonDescription; + AEPrintDescToHandle(&desc,&descHandle); + carbonDescription = [NSString stringWithUTF8String:*descHandle]; + DisposeHandle(descHandle); + return carbonDescription; +} + +NSAppleEventDescriptor *ITSendAE(FourCharCode eClass, FourCharCode eID, const ProcessSerialNumber *psn) { + AEDesc dest; + int pid; + AppleEvent event, reply; + OSStatus cerr, err; + NSAppleEventDescriptor *cocoaReply; + + if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) { + ITDebugLog(@"ITSendAE(%@, %@, {%i, %i}): Error getting PID of application.", NSStringFromFourCharCode(eClass), NSStringFromFourCharCode(eID), psn->highLongOfPSN, psn->lowLongOfPSN); + return nil; + } + + AECreateDesc(typeProcessSerialNumber, psn,sizeof(ProcessSerialNumber),&dest); + cerr = AECreateAppleEvent(eClass,eID,&dest,kAutoGenerateReturnID,kAnyTransactionID,&event); + + if (cerr) { + return nil; + } + + err = AESend(&event, &reply, kAENoReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL); + + if (err) { + return nil; + } + + return [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&reply] autorelease]; +} + +NSAppleEventDescriptor *ITSendAEWithKey(FourCharCode reqKey, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn) { + return ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%@'), from:'null'() }", NSStringFromFourCharCode(reqKey)], evClass, evID, psn); +} + +NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn) { + pid_t pid; + AppleEvent sendEvent, replyEvent; + AEDesc resultDesc; + DescType resultType; + Size resultSize; + + AEBuildError buildError; + OSStatus berr,err; + + if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) { + ITDebugLog(@"ITSendAEWithString(%@, %@, %@, {%i, %i}): Error getting PID of application.", sendString, NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN); + return nil; + } + + berr = AEBuildAppleEvent(evClass, evID, typeProcessSerialNumber,psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, [sendString UTF8String]); + + if (berr) { + ITDebugLog(@"ITSendAEWithString(%@, %@, %@, {%i, %i}): Build Error: %d:%d at \"%@\"", sendString, NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN, (int)buildError.fError, buildError.fErrorPos, [sendString substringToIndex:buildError.fErrorPos]); + return nil; + } + + err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL); + + if (err) { + ITDebugLog(@"ITSendAEWithString(%@, %@, %@, {%i, %i}): Send Error: %i", sendString, NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN, err); + return nil; + } + + err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize); + + if (resultSize == 0 || err != 0) { + return nil; + } + + AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc); + + return [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease]; +} + +NSAppleEventDescriptor *ITSendAEWithStringAndObject(NSString *sendString, const AEDesc *object, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn) { + pid_t pid; + AppleEvent sendEvent, replyEvent; + NSAppleEventDescriptor *recv; + AEDesc resultDesc; + DescType resultType; + Size resultSize; + + AEBuildError buildError; + OSStatus berr,err; + + if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) { + ITDebugLog(@"ITSendAEWithStringAndObject(%@, <%@>, %@, %@, {%i, %i}): Error getting PID of application.", sendString, _ITAEDescCarbonDescription(*object), NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN); + return nil; + } + + berr = AEBuildAppleEvent(evClass, evID, typeProcessSerialNumber,psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, [sendString UTF8String]); + + if (berr) { + ITDebugLog(@"ITSendAEWithStringAndObject(%@, <%@>, %@, %@, {%i, %i}): Build Error: %d:%d at \"%@\"", sendString, _ITAEDescCarbonDescription(*object), NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN, (int)buildError.fError, buildError.fErrorPos, [sendString substringToIndex:buildError.fErrorPos]); + return nil; + } + + AEPutParamDesc(&sendEvent, keyDirectObject, object); + + err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL); + + if (err) { + ITDebugLog(@"ITSendAEWithStringAndObject(%@, <%@>, %@, %@, {%i, %i}): Send Error: %i", sendString, _ITAEDescCarbonDescription(*object), NSStringFromFourCharCode(evClass), NSStringFromFourCharCode(evID), psn->highLongOfPSN, psn->lowLongOfPSN, err); + return nil; + } + + err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize); + + if (resultSize == 0 || err != 0) { + return nil; + } + + AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc); + + return [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease]; +} \ No newline at end of file diff --git a/ITCategory-NSAppleEventDescriptor.h b/ITCategory-NSAppleEventDescriptor.h new file mode 100644 index 0000000..bd909d0 --- /dev/null +++ b/ITCategory-NSAppleEventDescriptor.h @@ -0,0 +1,18 @@ +/* + * ITMac + * ITCategory-NSAppleEventDescriptor.h + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import + +@interface NSAppleEventDescriptor (ITMacCategory) + +- (NSString *)carbonDescription; + +@end \ No newline at end of file diff --git a/ITCategory-NSAppleEventDescriptor.m b/ITCategory-NSAppleEventDescriptor.m new file mode 100644 index 0000000..286efc7 --- /dev/null +++ b/ITCategory-NSAppleEventDescriptor.m @@ -0,0 +1,10 @@ +#import "ITCategory-NSAppleEventDescriptor.h" +#import "ITAppleEventTools.h" + +@implementation NSAppleEventDescriptor (ITMacCategory) + +- (NSString *)carbonDescription { + return _ITAEDescCarbonDescription(*[self aeDesc]); +} + +@end \ No newline at end of file diff --git a/ITMac.h b/ITMac.h new file mode 100644 index 0000000..caf8fc2 --- /dev/null +++ b/ITMac.h @@ -0,0 +1,14 @@ +/* + * ITMac + * ITMac.h + * + * iThink Software's wrappers and interfaces to the Mac toolbox. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import \ No newline at end of file diff --git a/ITMac.xcode/project.pbxproj b/ITMac.xcode/project.pbxproj new file mode 100644 index 0000000..85fed51 --- /dev/null +++ b/ITMac.xcode/project.pbxproj @@ -0,0 +1,697 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 014CEA440018CDF011CA2923 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + ZERO_LINK = YES; + }; + isa = PBXBuildStyle; + name = Development; + }; + 014CEA450018CDF011CA2923 = { + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + ZERO_LINK = NO; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//010 +//011 +//012 +//013 +//014 +//030 +//031 +//032 +//033 +//034 + 034768DFFF38A50411DB9C8B = { + children = ( + 8DC2EF5B0486A6940098B216, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; +//030 +//031 +//032 +//033 +//034 +//080 +//081 +//082 +//083 +//084 + 0867D690FE84028FC02AAC07 = { + buildSettings = { + MACOSX_DEPLOYMENT_TARGET = 10.2; + SDKROOT = /Developer/SDKs/MacOSX10.2.8.sdk; + }; + buildStyles = ( + 014CEA440018CDF011CA2923, + 014CEA450018CDF011CA2923, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 0867D691FE84028FC02AAC07; + productRefGroup = 034768DFFF38A50411DB9C8B; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 7C8250A807FB263B00147948; + ProjectRef = 7C8250A607FB263900147948; + }, + ); + targets = ( + 8DC2EF4F0486A6940098B216, + ); + }; + 0867D691FE84028FC02AAC07 = { + children = ( + 08FB77AEFE84172EC02AAC07, + 32C88DFF0371C24200C91783, + 089C1665FE841158C02AAC07, + 0867D69AFE84028FC02AAC07, + 034768DFFF38A50411DB9C8B, + ); + isa = PBXGroup; + name = ITMac; + refType = 4; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 = { + children = ( + 7C8250A607FB263900147948, + 1058C7B0FEA5585E11CA2CBB, + 1058C7B2FEA5585E11CA2CBB, + ); + isa = PBXGroup; + name = "External Frameworks and Libraries"; + refType = 4; + sourceTree = ""; + }; + 0867D69BFE84028FC02AAC07 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + sourceTree = ""; + }; + 0867D6A5FE840307C02AAC07 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + sourceTree = ""; + }; + 089C1665FE841158C02AAC07 = { + children = ( + 8DC2EF5A0486A6940098B216, + 089C1666FE841158C02AAC07, + ); + isa = PBXGroup; + name = Resources; + refType = 4; + sourceTree = ""; + }; + 089C1666FE841158C02AAC07 = { + children = ( + 089C1667FE841158C02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 089C1667FE841158C02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 08FB77AEFE84172EC02AAC07 = { + children = ( + 7C8250FD07FB287200147948, + 7C82510007FB287800147948, + 7C82510307FB288500147948, + ); + isa = PBXGroup; + name = Classes; + refType = 4; + sourceTree = ""; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7B0FEA5585E11CA2CBB = { + children = ( + 1058C7B1FEA5585E11CA2CBB, + 7C8253C107FBCEB700147948, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + sourceTree = ""; + }; + 1058C7B1FEA5585E11CA2CBB = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + sourceTree = ""; + }; + 1058C7B2FEA5585E11CA2CBB = { + children = ( + 0867D69BFE84028FC02AAC07, + 0867D6A5FE840307C02AAC07, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + sourceTree = ""; + }; +//100 +//101 +//102 +//103 +//104 +//320 +//321 +//322 +//323 +//324 + 32C88DFF0371C24200C91783 = { + children = ( + 7C8250C807FB272900147948, + 32DBCF5E0370ADEE00C91783, + ); + isa = PBXGroup; + name = "Other Sources"; + refType = 4; + sourceTree = ""; + }; + 32DBCF5E0370ADEE00C91783 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITMac_Prefix.pch; + refType = 4; + sourceTree = ""; + }; +//320 +//321 +//322 +//323 +//324 +//7C0 +//7C1 +//7C2 +//7C3 +//7C4 + 7C04624E0801E23100433407 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITPixmapListMacResource.h; + refType = 4; + sourceTree = ""; + }; + 7C04624F0801E23100433407 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITPixmapListMacResource.m; + refType = 4; + sourceTree = ""; + }; + 7C0462500801E23100433407 = { + fileRef = 7C04624E0801E23100433407; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 7C0462510801E23100433407 = { + fileRef = 7C04624F0801E23100433407; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250A607FB263900147948 = { + isa = PBXFileReference; + lastKnownFileType = "wrapper.pb-project"; + name = ITFoundation.xcode; + path = ../ITFoundation/ITFoundation.xcode; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 7C8250A807FB263B00147948 = { + children = ( + 7C8250A907FB263B00147948, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; + 7C8250A907FB263B00147948 = { + fileType = wrapper.framework; + isa = PBXReferenceProxy; + path = ITFoundation.framework; + refType = 3; + remoteRef = 7C8250B407FB265900147948; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 7C8250AC07FB264700147948 = { + fileRef = 7C8250A907FB263B00147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250B407FB265900147948 = { + containerPortal = 7C8250A607FB263900147948; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = 8DC2EF5B0486A6940098B216; + remoteInfo = ITFoundation; + }; + 7C8250BA07FB267400147948 = { + containerPortal = 7C8250A607FB263900147948; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = 8DC2EF4F0486A6940098B216; + remoteInfo = ITFoundation; + }; + 7C8250BB07FB267400147948 = { + isa = PBXTargetDependency; + name = "ITFoundation (from ITFoundation.xcode)"; + targetProxy = 7C8250BA07FB267400147948; + }; + 7C8250C807FB272900147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITMac.h; + refType = 4; + sourceTree = ""; + }; + 7C8250C907FB272900147948 = { + fileRef = 7C8250C807FB272900147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 7C8250DF07FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITAppleEventTools.h; + refType = 4; + sourceTree = ""; + }; + 7C8250E007FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITAppleEventTools.m; + refType = 4; + sourceTree = ""; + }; + 7C8250E107FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITMacResource.h; + refType = 4; + sourceTree = ""; + }; + 7C8250E207FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITMacResource.m; + refType = 4; + sourceTree = ""; + }; + 7C8250E307FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITMacResourceFile.h; + refType = 4; + sourceTree = ""; + }; + 7C8250E407FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITMacResourceFile.m; + refType = 4; + sourceTree = ""; + }; + 7C8250E507FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITOSAComponent.h; + refType = 4; + sourceTree = ""; + }; + 7C8250E607FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITOSAComponent.m; + refType = 4; + sourceTree = ""; + }; + 7C8250E707FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITOSAScript.h; + refType = 4; + sourceTree = ""; + }; + 7C8250E807FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITOSAScript.m; + refType = 4; + sourceTree = ""; + }; + 7C8250E907FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITStringMacResource.h; + refType = 4; + sourceTree = ""; + }; + 7C8250EA07FB286500147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITStringMacResource.m; + refType = 4; + sourceTree = ""; + }; + 7C8250EF07FB286500147948 = { + fileRef = 7C8250DF07FB286500147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 7C8250F007FB286500147948 = { + fileRef = 7C8250E007FB286500147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250F107FB286500147948 = { + fileRef = 7C8250E107FB286500147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 7C8250F207FB286500147948 = { + fileRef = 7C8250E207FB286500147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250F307FB286500147948 = { + fileRef = 7C8250E307FB286500147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 7C8250F407FB286500147948 = { + fileRef = 7C8250E407FB286500147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250F907FB286500147948 = { + fileRef = 7C8250E907FB286500147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + 7C8250FA07FB286500147948 = { + fileRef = 7C8250EA07FB286500147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8250FD07FB287200147948 = { + children = ( + 7C82514107FB4ADA00147948, + 7C82514207FB4ADA00147948, + 7C8250DF07FB286500147948, + 7C8250E007FB286500147948, + ); + isa = PBXGroup; + name = AppleEvents; + refType = 4; + sourceTree = ""; + }; + 7C82510007FB287800147948 = { + children = ( + 7C8250E307FB286500147948, + 7C8250E407FB286500147948, + 7C8250E107FB286500147948, + 7C8250E207FB286500147948, + 7C8250E907FB286500147948, + 7C8250EA07FB286500147948, + 7C04624E0801E23100433407, + 7C04624F0801E23100433407, + ); + isa = PBXGroup; + name = ResourceManager; + path = ""; + refType = 4; + sourceTree = ""; + }; + 7C82510307FB288500147948 = { + children = ( + 7C8250E507FB286500147948, + 7C8250E607FB286500147948, + 7C8250E707FB286500147948, + 7C8250E807FB286500147948, + ); + isa = PBXGroup; + name = OpenScripting; + refType = 4; + sourceTree = ""; + }; + 7C82514107FB4ADA00147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = "ITCategory-NSAppleEventDescriptor.h"; + refType = 4; + sourceTree = ""; + }; + 7C82514207FB4ADA00147948 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = "ITCategory-NSAppleEventDescriptor.m"; + refType = 4; + sourceTree = ""; + }; + 7C82514307FB4ADA00147948 = { + fileRef = 7C82514107FB4ADA00147948; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 7C82514407FB4ADA00147948 = { + fileRef = 7C82514207FB4ADA00147948; + isa = PBXBuildFile; + settings = { + }; + }; + 7C8253C107FBCEB700147948 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Carbon.framework; + path = /System/Library/Frameworks/Carbon.framework; + refType = 0; + sourceTree = ""; + }; + 7C8253C207FBCEB700147948 = { + fileRef = 7C8253C107FBCEB700147948; + isa = PBXBuildFile; + settings = { + }; + }; +//7C0 +//7C1 +//7C2 +//7C3 +//7C4 +//8D0 +//8D1 +//8D2 +//8D3 +//8D4 + 8DC2EF4F0486A6940098B216 = { + buildPhases = ( + 8DC2EF500486A6940098B216, + 8DC2EF520486A6940098B216, + 8DC2EF540486A6940098B216, + 8DC2EF560486A6940098B216, + ); + buildRules = ( + ); + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = /Volumes/Data/Projects/ITMac; + FRAMEWORK_VERSION = A; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = ITMac_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = DYNAMIC; + MACOSX_DEPLOYMENT_TARGET = 10.2; + OTHER_LDFLAGS = "-seg1addr 0x17500000"; + PRODUCT_NAME = ITMac; + WRAPPER_EXTENSION = framework; + }; + dependencies = ( + 7C8250BB07FB267400147948, + ); + isa = PBXNativeTarget; + name = ITMac; + productInstallPath = "$(HOME)/Library/Frameworks"; + productName = ITMac; + productReference = 8DC2EF5B0486A6940098B216; + productType = "com.apple.product-type.framework"; + }; + 8DC2EF500486A6940098B216 = { + buildActionMask = 2147483647; + files = ( + 7C8250C907FB272900147948, + 7C8250EF07FB286500147948, + 7C8250F107FB286500147948, + 7C8250F307FB286500147948, + 7C8250F907FB286500147948, + 7C82514307FB4ADA00147948, + 7C0462500801E23100433407, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8DC2EF520486A6940098B216 = { + buildActionMask = 2147483647; + files = ( + 8DC2EF530486A6940098B216, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8DC2EF530486A6940098B216 = { + fileRef = 089C1666FE841158C02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; + 8DC2EF540486A6940098B216 = { + buildActionMask = 2147483647; + files = ( + 7C8250F007FB286500147948, + 7C8250F207FB286500147948, + 7C8250F407FB286500147948, + 7C8250FA07FB286500147948, + 7C82514407FB4ADA00147948, + 7C0462510801E23100433407, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8DC2EF560486A6940098B216 = { + buildActionMask = 2147483647; + files = ( + 8DC2EF570486A6940098B216, + 7C8250AC07FB264700147948, + 7C8253C207FBCEB700147948, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8DC2EF570486A6940098B216 = { + fileRef = 1058C7B1FEA5585E11CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; + 8DC2EF5A0486A6940098B216 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = text.plist; + path = Info.plist; + refType = 4; + sourceTree = ""; + }; + 8DC2EF5B0486A6940098B216 = { + explicitFileType = wrapper.framework; + includeInIndex = 0; + isa = PBXFileReference; + path = ITMac.framework; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + }; + rootObject = 0867D690FE84028FC02AAC07; +} diff --git a/ITMacResource.h b/ITMacResource.h new file mode 100644 index 0000000..f1afd33 --- /dev/null +++ b/ITMacResource.h @@ -0,0 +1,42 @@ +/* + * ITMac + * ITMacResource.h + * + * Class that wraps Carbon ResourceManager resources. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import + +typedef ResType ITMacResourceType; + +@interface ITMacResource : NSObject { + @protected + Handle _handle; +} + ++ (Class)subclassForType:(ITMacResourceType)type; + ++ (NSArray *)supportedResourceTypes; ++ (BOOL)supportsResourceType:(ITMacResourceType)type; + ++ (id)resourceWithHandle:(Handle)handle; +- (id)initWithHandle:(Handle)handle; + +- (Handle)handle; + +- (NSData *)data; +- (ITMacResourceType)type; +- (short)id; +- (NSString *)name; + +- (Class)nativeRepresentationClass; +- (id)nativeRepresentation; + +@end \ No newline at end of file diff --git a/ITMacResource.m b/ITMacResource.m new file mode 100644 index 0000000..4becbc4 --- /dev/null +++ b/ITMacResource.m @@ -0,0 +1,89 @@ +#import "ITMacResource.h" + +@implementation ITMacResource + ++ (Class)subclassForType:(ITMacResourceType)type { + NSEnumerator *subclassEnumerator = [[self subclasses] objectEnumerator]; + Class subclass; + + while ((subclass = [subclassEnumerator nextObject])) { + if ([subclass supportsResourceType:type]) { + return subclass; + } + } + + return self; +} + ++ (NSArray *)supportedResourceTypes { + return [NSArray array]; +} + ++ (BOOL)supportsResourceType:(ITMacResourceType)type { + return [[self supportedResourceTypes] containsObject:[NSString stringWithFourCharCode:type]]; +} + ++ (id)resourceWithHandle:(Handle)handle { + return [[[self alloc] initWithHandle:handle] autorelease]; +} + +- (id)initWithHandle:(Handle)handle { + if (self = [super init]) { + _handle = handle; + } + return self; +} + +- (Handle)handle { + return _handle; +} + +- (NSData *)data { + NSData *_data; + HLock(_handle); + _data = [NSData dataWithBytes:(*_handle) length:GetHandleSize(_handle)]; + HUnlock(_handle); + return _data; +} + +- (ITMacResourceType)type { + short _id; + ResType _type; + Str255 _name; + GetResInfo(_handle, &_id, &_type, _name); + return (ITMacResourceType)_type; +} + +- (short)id { + short _id; + ResType _type; + Str255 _name; + GetResInfo(_handle, &_id, &_type, _name); + return _id; +} + +- (NSString *)name { + short _id; + ResType _type; + Str255 _name; + GetResInfo(_handle, &_id, &_type, _name); + return [(NSString*)CFStringCreateWithPascalString(NULL, +_name, kCFStringEncodingMacRomanLatin1) autorelease]; +} + +- (Class)nativeRepresentationClass { + return nil; +} + +- (id)nativeRepresentation { + return nil; +} + +- (void)dealloc { + if (_handle) { + ReleaseResource(_handle); + } + [super dealloc]; +} + +@end \ No newline at end of file diff --git a/ITMacResourceFile.h b/ITMacResourceFile.h new file mode 100644 index 0000000..9e245fa --- /dev/null +++ b/ITMacResourceFile.h @@ -0,0 +1,32 @@ +/* + * ITMac + * ITMacResourceFile.h + * + * Class that wraps Carbon ResourceManager resource files. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import +#import "ITMacResource.h" + +@interface ITMacResourceFile : NSObject { + FSRef _fileReference; + SInt16 _referenceNumber; +} + ++ (HFSUniStr255)dataForkName; ++ (HFSUniStr255)resourceForkName; + +- (id)initWithContentsOfFile:(NSString *)path; +- (id)initWithContentsOfFile:(NSString *)path fork:(HFSUniStr255)namedFork; + +- (ITMacResource *)resourceOfType:(ITMacResourceType)type withID:(short)idNum; +- (ITMacResource *)resourceOfType:(ITMacResourceType)type withName:(NSString *)name; + +@end \ No newline at end of file diff --git a/ITMacResourceFile.m b/ITMacResourceFile.m new file mode 100644 index 0000000..39cc3ce --- /dev/null +++ b/ITMacResourceFile.m @@ -0,0 +1,57 @@ +#import "ITMacResourceFile.h" + +@implementation ITMacResourceFile + ++ (HFSUniStr255)dataForkName { + HFSUniStr255 dataForkName; + FSGetDataForkName(&dataForkName); + return dataForkName; +} + ++ (HFSUniStr255)resourceForkName { + HFSUniStr255 resourceForkName; + FSGetResourceForkName(&resourceForkName); + return resourceForkName; +} + +- (id)initWithContentsOfFile:(NSString *)path { + return [self initWithContentsOfFile:path fork:[ITMacResourceFile dataForkName]]; +} + +- (id)initWithContentsOfFile:(NSString *)path fork:(HFSUniStr255)namedFork { + if (self = [super init]) { + if (FSPathMakeRef([path fileSystemRepresentation], &_fileReference, NULL) == noErr) { + FSOpenResourceFile(&_fileReference, namedFork.length, namedFork.unicode, fsRdPerm, &_referenceNumber); + } else { + [super release]; + self = nil; + } + } + return self; +} + +- (ITMacResource *)resourceOfType:(ITMacResourceType)type withID:(short)idNum { + return [[ITMacResource subclassForType:type] resourceWithHandle:GetResource((ResType)type, idNum)]; +} + +- (ITMacResource *)resourceOfType:(ITMacResourceType)type withName:(NSString *)name { + Str255 _buffer; + StringPtr _ptr = (StringPtr)CFStringGetPascalStringPtr((CFStringRef)name, kCFStringEncodingMacRomanLatin1); + if (_ptr == NULL) { + if (CFStringGetPascalString((CFStringRef)name, _buffer, 256, kCFStringEncodingMacRomanLatin1)) { + _ptr = _buffer; + } else { + return nil; + } + } + return [[ITMacResource subclassForType:type] resourceWithHandle:GetNamedResource((ResType)type,_ptr)]; +} + +- (void)dealloc { + if (_referenceNumber) { + CloseResFile(_referenceNumber); + } + [super dealloc]; +} + +@end \ No newline at end of file diff --git a/ITMac_Prefix.pch b/ITMac_Prefix.pch new file mode 100644 index 0000000..f472ac9 --- /dev/null +++ b/ITMac_Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'ITMac' target in the 'ITMac' project. +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/ITOSAComponent.h b/ITOSAComponent.h new file mode 100644 index 0000000..f8727d0 --- /dev/null +++ b/ITOSAComponent.h @@ -0,0 +1,34 @@ +/* + * ITMac + * ITOSAComponent.h + * + * Class that wraps OpenScripting components. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import + +@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 \ No newline at end of file diff --git a/ITOSAComponent.m b/ITOSAComponent.m new file mode 100644 index 0000000..35078aa --- /dev/null +++ b/ITOSAComponent.m @@ -0,0 +1,113 @@ +#import "ITOSAComponent.h" + +// 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 diff --git a/ITOSAScript.h b/ITOSAScript.h new file mode 100644 index 0000000..7a408af --- /dev/null +++ b/ITOSAScript.h @@ -0,0 +1,38 @@ +/* + * ITMac + * ITOSAScript.h + * + * Class that wraps OpenScripting scripts. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import + +@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 \ No newline at end of file diff --git a/ITOSAScript.m b/ITOSAScript.m new file mode 100644 index 0000000..ff6537b --- /dev/null +++ b/ITOSAScript.m @@ -0,0 +1,112 @@ +/* +Script Subtypes: + kAppleScriptSubtype - AppleScript (Default) + 'Jscr' - JavaScript (if installed) +*/ + +#import "ITOSAScript.h" +#import "ITOSAComponent.h" + +// 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 diff --git a/ITPixmapListMacResource.h b/ITPixmapListMacResource.h new file mode 100644 index 0000000..8a72bdb --- /dev/null +++ b/ITPixmapListMacResource.h @@ -0,0 +1,21 @@ +/* + * ITMac + * ITPixmapListMacResource.h + * + * Class that wraps Carbon ResourceManager resources of type 'pxm#'. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import "ITMacResource.h" + +@interface ITPixmapListMacResource : ITMacResource { + +} + +@end \ No newline at end of file diff --git a/ITPixmapListMacResource.m b/ITPixmapListMacResource.m new file mode 100644 index 0000000..8e2d449 --- /dev/null +++ b/ITPixmapListMacResource.m @@ -0,0 +1,17 @@ +#import "ITPixmapListMacResource.h" + +@implementation ITPixmapListMacResource + ++ (NSArray *)supportedResourceTypes { + return [NSArray arrayWithObject:[NSString stringWithFourCharCode:'pxm#']]; +} + +- (Class)nativeRepresentationClass { + return [NSArray class]; +} + +- (id)nativeRepresentation { + return nil; +} + +@end \ No newline at end of file diff --git a/ITStringMacResource.h b/ITStringMacResource.h new file mode 100644 index 0000000..2a2bb8e --- /dev/null +++ b/ITStringMacResource.h @@ -0,0 +1,21 @@ +/* + * ITMac + * ITStringMacResource.h + * + * Class that wraps Carbon ResourceManager resources of type 'STR '. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ + +#import +#import "ITMacResource.h" + +@interface ITStringMacResource : ITMacResource { + +} + +@end \ No newline at end of file diff --git a/ITStringMacResource.m b/ITStringMacResource.m new file mode 100644 index 0000000..cf435d6 --- /dev/null +++ b/ITStringMacResource.m @@ -0,0 +1,17 @@ +#import "ITStringMacResource.h" + +@implementation ITStringMacResource + ++ (NSArray *)supportedResourceTypes { + return [NSArray arrayWithObject:[NSString stringWithFourCharCode:'STR ']]; +} + +- (Class)nativeRepresentationClass { + return [NSString class]; +} + +- (id)nativeRepresentation { + return nil; +} + +@end \ No newline at end of file diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..39c28e0 --- /dev/null +++ b/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ITMac + CFBundleIconFile + + CFBundleIdentifier + com.ithinksw.itmac + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ITmc + CFBundleVersion + 1.0 + NSPrincipalClass + + + diff --git a/version.plist b/version.plist new file mode 100644 index 0000000..53bf3a3 --- /dev/null +++ b/version.plist @@ -0,0 +1,16 @@ + + + + + BuildVersion + 12 + CFBundleVersion + 1.0 + ProductBuildVersion + 7K571 + ProjectName + DevToolsWizardTemplates + SourceVersion + 3870000 + +