home *** CD-ROM | disk | FTP | other *** search
- #ifndef __AEEXTRAS__
- #define __AEEXTRAS__
- #pragma once
-
- /*
-
- Stuff which should be in the AppleEvent manager but isn't
-
- */
-
- // JimC 980225 NOTE - this stuff should NEVER throw an exception
- // they don't, this is just a reminder to myself :)
-
- #include <AppleEvents.h>
- #include <AERegistry.h>
- #include <ASRegistry.h>
- #include <Processes.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- enum
- {
- typeCString = 'strC', // null terminated string
- typePString = 'strP', // pascal string
-
- typePropertyID = 'pID ', // a property ID (4-char code)
- typeClassID = 'cID ', // a class ID (4-char code)
-
- typeTypedData = 'TypD', // type/data
- typeFlattenedDesc = 'fDsc', // type/size/data
-
- typeDataSize = 'Dsiz', // data size - used for GetDataSize
- typeDataExists = 'Xist', // data exists - used for Exists
- typeElemCount = 'Xcnt', // data exists - used for Exists
- typeDataType = 'Dtyp', // data type
-
- typeUniversalTime = 'gmt ', //
-
- typeDateTimeZone = 'ldtZ', // 'ldt ' w/time zone
- // typeUnivDateTime = 'ldtG', // typeLongDateTime converted to GMT
-
- keyAESingleObject = '1obj',
-
- // Pseudo key forms:
- formSelf = 'self', // psudo key-form to refer to the container in AEObjectSpec
- formData = 'data', // psudo key-form to refer to pure data in an AEObjectSpec
- formPropertyTest = 'pTst',
-
- // Absolute ordinals
- formAll = kAEAll,
- formFirst = kAEFirst,
- formLast = kAELast,
- formMiddle = kAEMiddle,
- formAny = kAEAny,
-
- // Insertion locations
- formIn = keyASPrepositionIn,
- formBeginning = kAEBeginning,
- formEnd = kAEEnd,
- formBefore = kAEBefore,
- formAfter = kAEAfter,
- formReplace = kAEReplace,
-
- // pData = 'data', /* 0x64617461 == keyAEData */
- // pValue = 'valu'
- // pExists = 'have'
-
- keyAEEventTargetAttr = 'disp', // object spcifier for object event is being sent to ==
- keyAETargetTokenAttr = 'tokn', // token from resolving keyAEEventTargetAttr
-
- // extra AppleEvent error parameters
-
- keyAEErrorActualType = 'aTyp', // Actual type in a coercion failure
- keyAEErrorFile = 'File', // File the error occurred in
- keyAEErrorLine = 'Line', // Line the error occurred on
- keyAEErrorFunc = 'File', // Function the error occurred in
-
- zzzzxz
- };
-
-
- enum {
- kOSAModeDispatchToSubject = 0x20000000 // dispatch event to subject attr
- };
-
- pascal OSErr InitAEExtras(AEIdleUPP idle, AEFilterUPP filter);
-
- pascal void XAEInstallCoerceDescProc(
- DescType fromType,
- DescType toType,
- AECoerceDescProcPtr handler);
-
- pascal void XAEInstallCoercePtrProc(
- DescType fromType,
- DescType toType,
- AECoercePtrProcPtr handler);
-
- pascal OSErr TempAECreateDesc(
- DescType typeCode,
- const void* dataPtr,
- Size dataSize,
- AEDesc *result);
-
- pascal OSErr TempAEDuplicateDesc(
- const AEDesc *source,
- AEDesc *dest);
-
- pascal OSErr XAEGetCoercionHandler(
- DescType fromType,
- DescType toType,
- AECoercionHandlerUPP* handler,
- long* handlerRefcon,
- Boolean* fromTypeIsDesc,
- AECoercionHandlerUPP skipMe = nil);
- // Gets the handler that the system would call for a given from/to type
-
- pascal OSErr XAECoercePtr(
- DescType typeCode,
- const void* dataPtr,
- Size dataSize,
- DescType toType,
- AEDesc* result);
- // Same as AECoercePtr, but can be called form a coercion handler
-
- pascal OSErr XAECoerceDesc(
- const AEDesc* theAEDesc,
- DescType toType,
- AEDesc* result);
- // Same as AECoerceDesc, but can be called form a coercion handler
-
-
- pascal OSErr AEGetDescPtr(
- const AEDesc* theAEDesc,
- DescType desiredType,
- DescType* typeCode,
- void* dataPtr,
- Size maximumSize,
- Size* actualSize);
- // Gets the data out of an AEDesc with coercion as necessary,
- // providing an API consistant with AEGetXXXPtr, etc.
-
- pascal OSErr AEParseInsertionLocation(
- const AEDesc* insertLoc,
- AEDesc* container, // the affected container
- DescType* position, // the position enumeration
- AEDesc* reference, // objects to be replaced
- DescType* refClass); // class of reference
-
- pascal OSErr AEParseObjectSpecifier(
- const AEDesc* object,
- DescType* desiredClass,
- AEDesc* container,
- DescType* keyForm,
- AEDesc* keyData);
-
- // routines for taking apart object specifiers and insertion locations
- // note that eiter routine will accept an object specifier or an
- // insertion location but handle them slightly differently -- if an
- // object specifier is passed to AEParseInsertionLocation it will be
- // returned as the container and position will be fromIn -- if an
- // insertion location is passed to AEParseObjectSpecifier, container
- // will be the container where the insertion is to occur, keyForm
- // will be the position, keyData will be the reference object (if any),
- // and desiredClass will be the class of the reference object if present
-
- DescType IsObjectSpecifier(const AEDesc* desc);
-
- DescType IsObjectSpecifierOrInsertion(const AEDesc* desc);
-
- DescType GetUniformItemType(const AEDesc* list, DescType type = 0, bool recursive = false);
- // given an AEList check if all elements are the same type and
- // return the type (or 0)
-
- DescType GetUniformObjectClass(const AEDesc* list, DescType type = 0, bool recursive = false);
- // if list is a list of object specifiers, determine is all specify the same class
- // returns 0 if not all are object specs, cObject if all are object specs
- // or other type if all are objects specs of uniform type
-
- pascal OSErr AEGetEventTarget(
- const AppleEvent* event,
- AEDesc* target,
- /*
- DescType* containerClass,
- */
- DescType* desiredClass,
- /* DescType* keyForm,
- AEDesc* keyData,
- */
- long flags = 0,
- AEKeyword* source = nil);
- // This routine calculates the object that it the target of the
- // event. The logic is:
- // keyAEEventTargetAttr if present
- // container of keyAEInsertHere if present
- // keyDirectObject if an object specifier
- // keySubjectAttr if present
-
- // at the moment we support kOSAModeDispatchToDirectObject and
- // kOSAModeDispatchToSubject for mode flags
-
- pascal OSErr AECopyParams(const AERecord *src, AERecord *dst, Boolean overwrite);
- // copies all key params of src to dst. If dst is a null descriptor
- // it is created, otherwise they are merged. If dst is a null descriptor
- // nothing happens
-
- pascal long RandomInRange(long start, long end);
-
- extern const ProcessSerialNumber kAESelfPSN;
-
- const AEAddressDesc* AEGetSelfAddress();
- AEIdleUPP AEGetDefaultIdleProc(void);
- AEIdleUPP AESetDefaultIdleProc(AEIdleUPP newProc);
- AEFilterUPP AEGetDefaultFilterProc(void);
- AEFilterUPP AESetDefaultFilterProc(AEFilterUPP newProc);
-
- OSErr AEBuildEventToSelf(AppleEvent* event, AEEventClass theAEEventClass, AEEventID theAEEventID, char* format, ...);
- OSErr AESendEventToSelf(AEEventClass theAEEventClass, AEEventID theAEEventID, long addition_send_flags, AppleEvent *reply, char* format, ...);
- OSErr AECreateEventToSelf(AEEventClass theAEEventClass, AEEventID theAEEventID, AppleEvent *event, const AEDesc *target = nil);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif __AEEXTRAS__
-
-
-