home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / AppleEvents.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  15.6 KB  |  2 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        AppleEvents.h
  3.  
  4.      Contains:    AppleEvent Package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1989-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __APPLEEVENTS__
  18. #define __APPLEEVENTS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __NOTIFICATION__
  29.     #include <Notification.h>
  30. #endif
  31.  
  32. #ifndef __EVENTS__
  33.     #include <Events.h>
  34. #endif
  35.  
  36. /*
  37.     Note:    The functions and types for the building and parsing AppleEvent  
  38.             messages has moved to AEDataModel.h
  39. */
  40. #ifndef __AEDATAMODEL__
  41.     #include <AEDataModel.h>
  42. #endif
  43.  
  44.  
  45.  
  46.  
  47. #if PRAGMA_ONCE
  48. #pragma once
  49. #endif
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if PRAGMA_IMPORT
  56. #pragma import on
  57. #endif
  58.  
  59. #if PRAGMA_STRUCT_ALIGN
  60.     #pragma options align=mac68k
  61. #elif PRAGMA_STRUCT_PACKPUSH
  62.     #pragma pack(push, 2)
  63. #elif PRAGMA_STRUCT_PACK
  64.     #pragma pack(2)
  65. #endif
  66.  
  67. enum {
  68.                                                                 /* Keywords for Apple event parameters */
  69.     keyDirectObject                = FOUR_CHAR_CODE('----'),
  70.     keyErrorNumber                = FOUR_CHAR_CODE('errn'),
  71.     keyErrorString                = FOUR_CHAR_CODE('errs'),
  72.     keyProcessSerialNumber        = FOUR_CHAR_CODE('psn '),        /* Keywords for special handlers */
  73.     keyPreDispatch                = FOUR_CHAR_CODE('phac'),        /* preHandler accessor call */
  74.     keySelectProc                = FOUR_CHAR_CODE('selh'),        /* more selector call */
  75.                                                                 /* Keyword for recording */
  76.     keyAERecorderCount            = FOUR_CHAR_CODE('recr'),        /* available only in vers 1.0.1 and greater */
  77.                                                                 /* Keyword for version information */
  78.     keyAEVersion                = FOUR_CHAR_CODE('vers')        /* available only in vers 1.0.1 and greater */
  79. };
  80.  
  81. /* Event Class */
  82. enum {
  83.     kCoreEventClass                = FOUR_CHAR_CODE('aevt')
  84. };
  85.  
  86. /* Event ID's */
  87. enum {
  88.     kAEOpenApplication            = FOUR_CHAR_CODE('oapp'),
  89.     kAEOpenDocuments            = FOUR_CHAR_CODE('odoc'),
  90.     kAEPrintDocuments            = FOUR_CHAR_CODE('pdoc'),
  91.     kAEQuitApplication            = FOUR_CHAR_CODE('quit'),
  92.     kAEAnswer                    = FOUR_CHAR_CODE('ansr'),
  93.     kAEApplicationDied            = FOUR_CHAR_CODE('obit')
  94. };
  95.  
  96. /* Constants for recording */
  97. enum {
  98.     kAEStartRecording            = FOUR_CHAR_CODE('reca'),        /* available only in vers 1.0.1 and greater */
  99.     kAEStopRecording            = FOUR_CHAR_CODE('recc'),        /* available only in vers 1.0.1 and greater */
  100.     kAENotifyStartRecording        = FOUR_CHAR_CODE('rec1'),        /* available only in vers 1.0.1 and greater */
  101.     kAENotifyStopRecording        = FOUR_CHAR_CODE('rec0'),        /* available only in vers 1.0.1 and greater */
  102.     kAENotifyRecording            = FOUR_CHAR_CODE('recr')        /* available only in vers 1.0.1 and greater */
  103. };
  104.  
  105.  
  106. /* parameter to AESend */
  107. typedef OptionBits                         AESendOptions;
  108. enum {
  109.     kAENeverInteract            = 0x00000010,                    /* server should not interact with user */
  110.     kAECanInteract                = 0x00000020,                    /* server may try to interact with user */
  111.     kAEAlwaysInteract            = 0x00000030,                    /* server should always interact with user where appropriate */
  112.     kAECanSwitchLayer            = 0x00000040,                    /* interaction may switch layer */
  113.     kAEDontRecord                = 0x00001000,                    /* don't record this event - available only in vers 1.0.1 and greater */
  114.     kAEDontExecute                = 0x00002000,                    /* don't send the event for recording - available only in vers 1.0.1 and greater */
  115.     kAEProcessNonReplyEvents    = 0x00008000                    /* allow processing of non-reply events while awaiting synchronous AppleEvent reply */
  116. };
  117.  
  118. typedef SInt32                             AESendMode;
  119. enum {
  120.     kAENoReply                    = 0x00000001,                    /* sender doesn't want a reply to event */
  121.     kAEQueueReply                = 0x00000002,                    /* sender wants a reply but won't wait */
  122.     kAEWaitReply                = 0x00000003,                    /* sender wants a reply and will wait */
  123.     kAEDontReconnect            = 0x00000080,                    /* don't reconnect if there is a sessClosedErr from PPCToolbox */
  124.     kAEWantReceipt                = 0x00000200                    /* (nReturnReceipt) sender wants a receipt of message */
  125. };
  126.  
  127.  
  128. /* Constants for timeout durations */
  129. enum {
  130.     kAEDefaultTimeout            = -1,                            /* timeout value determined by AEM */
  131.     kNoTimeOut                    = -2                            /* wait until reply comes back, however long it takes */
  132. };
  133.  
  134.  
  135. /* priority param of AESend */
  136. typedef SInt16                             AESendPriority;
  137. enum {
  138.     kAENormalPriority            = 0x00000000,                    /* post message at the end of the event queue */
  139.     kAEHighPriority                = 0x00000001                    /* post message at the front of the event queue (same as nAttnMsg) */
  140. };
  141.  
  142.  
  143. typedef SInt8                             AEEventSource;
  144. enum {
  145.     kAEUnknownSource            = 0,
  146.     kAEDirectCall                = 1,
  147.     kAESameProcess                = 2,
  148.     kAELocalProcess                = 3,
  149.     kAERemoteProcess            = 4
  150. };
  151.  
  152.  
  153.  
  154. typedef CALLBACK_API( OSErr , AEEventHandlerProcPtr )(const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefcon);
  155. typedef CALLBACK_API( Boolean , AEIdleProcPtr )(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn);
  156. typedef CALLBACK_API( Boolean , AEFilterProcPtr )(EventRecord *theEvent, long returnID, long transactionID, const AEAddressDesc *sender);
  157. typedef STACK_UPP_TYPE(AEEventHandlerProcPtr)                     AEEventHandlerUPP;
  158. typedef STACK_UPP_TYPE(AEIdleProcPtr)                             AEIdleUPP;
  159. typedef STACK_UPP_TYPE(AEFilterProcPtr)                         AEFilterUPP;
  160. #if OPAQUE_UPP_TYPES
  161.     EXTERN_API(AEEventHandlerUPP)
  162.     NewAEEventHandlerUPP           (AEEventHandlerProcPtr    userRoutine);
  163.  
  164.     EXTERN_API(AEIdleUPP)
  165.     NewAEIdleUPP                   (AEIdleProcPtr            userRoutine);
  166.  
  167.     EXTERN_API(AEFilterUPP)
  168.     NewAEFilterUPP                   (AEFilterProcPtr            userRoutine);
  169.  
  170.     EXTERN_API(void)
  171.     DisposeAEEventHandlerUPP       (AEEventHandlerUPP        userUPP);
  172.  
  173.     EXTERN_API(void)
  174.     DisposeAEIdleUPP               (AEIdleUPP                userUPP);
  175.  
  176.     EXTERN_API(void)
  177.     DisposeAEFilterUPP               (AEFilterUPP                userUPP);
  178.  
  179.     EXTERN_API(OSErr)
  180.     InvokeAEEventHandlerUPP           (const AppleEvent *        theAppleEvent,
  181.                                     AppleEvent *            reply,
  182.                                     UInt32                    handlerRefcon,
  183.                                     AEEventHandlerUPP        userUPP);
  184.  
  185.     EXTERN_API(Boolean)
  186.     InvokeAEIdleUPP                   (EventRecord *            theEvent,
  187.                                     long *                    sleepTime,
  188.                                     RgnHandle *                mouseRgn,
  189.                                     AEIdleUPP                userUPP);
  190.  
  191.     EXTERN_API(Boolean)
  192.     InvokeAEFilterUPP               (EventRecord *            theEvent,
  193.                                     long                    returnID,
  194.                                     long                    transactionID,
  195.                                     const AEAddressDesc *    sender,
  196.                                     AEFilterUPP                userUPP);
  197.  
  198. #else
  199.     enum { uppAEEventHandlerProcInfo = 0x00000FE0 };                 /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  200.     enum { uppAEIdleProcInfo = 0x00000FD0 };                         /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes) */
  201.     enum { uppAEFilterProcInfo = 0x00003FD0 };                         /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  202.     #define NewAEEventHandlerUPP(userRoutine)                         (AEEventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEEventHandlerProcInfo, GetCurrentArchitecture())
  203.     #define NewAEIdleUPP(userRoutine)                                 (AEIdleUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture())
  204.     #define NewAEFilterUPP(userRoutine)                             (AEFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEFilterProcInfo, GetCurrentArchitecture())
  205.     #define DisposeAEEventHandlerUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  206.     #define DisposeAEIdleUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  207.     #define DisposeAEFilterUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  208.     #define InvokeAEEventHandlerUPP(theAppleEvent, reply, handlerRefcon, userUPP)  (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppAEEventHandlerProcInfo, (theAppleEvent), (reply), (handlerRefcon))
  209.     #define InvokeAEIdleUPP(theEvent, sleepTime, mouseRgn, userUPP)  (Boolean)CALL_THREE_PARAMETER_UPP((userUPP), uppAEIdleProcInfo, (theEvent), (sleepTime), (mouseRgn))
  210.     #define InvokeAEFilterUPP(theEvent, returnID, transactionID, sender, userUPP)  (Boolean)CALL_FOUR_PARAMETER_UPP((userUPP), uppAEFilterProcInfo, (theEvent), (returnID), (transactionID), (sender))
  211. #endif
  212. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  213. #define NewAEEventHandlerProc(userRoutine)                         NewAEEventHandlerUPP(userRoutine)
  214. #define NewAEIdleProc(userRoutine)                                 NewAEIdleUPP(userRoutine)
  215. #define NewAEFilterProc(userRoutine)                             NewAEFilterUPP(userRoutine)
  216. #define CallAEEventHandlerProc(userRoutine, theAppleEvent, reply, handlerRefcon) InvokeAEEventHandlerUPP(theAppleEvent, reply, handlerRefcon, userRoutine)
  217. #define CallAEIdleProc(userRoutine, theEvent, sleepTime, mouseRgn) InvokeAEIdleUPP(theEvent, sleepTime, mouseRgn, userRoutine)
  218. #define CallAEFilterProc(userRoutine, theEvent, returnID, transactionID, sender) InvokeAEFilterUPP(theEvent, returnID, transactionID, sender, userRoutine)
  219.  
  220. /**************************************************************************
  221.   The next couple of calls are basic routines used to create, send,
  222.   and process AppleEvents. 
  223. **************************************************************************/
  224. EXTERN_API( OSErr )
  225. AESend                            (const AppleEvent *        theAppleEvent,
  226.                                  AppleEvent *            reply,
  227.                                  AESendMode             sendMode,
  228.                                  AESendPriority         sendPriority,
  229.                                  long                     timeOutInTicks,
  230.                                  AEIdleUPP                 idleProc, /* can be NULL */
  231.                                  AEFilterUPP             filterProc) /* can be NULL */        THREEWORDINLINE(0x303C, 0x0D17, 0xA816);
  232.  
  233. EXTERN_API( OSErr )
  234. AEProcessAppleEvent                (const EventRecord *    theEventRecord)                        THREEWORDINLINE(0x303C, 0x021B, 0xA816);
  235.  
  236.  
  237. /* 
  238.  Note: during event processing, an event handler may realize that it is likely
  239.  to exceed the client's timeout limit. Passing the reply to this
  240.  routine causes a wait event to be generated that asks the client
  241.  for more time. 
  242. */
  243. EXTERN_API( OSErr )
  244. AEResetTimer                    (const AppleEvent *        reply)                                THREEWORDINLINE(0x303C, 0x0219, 0xA816);
  245.  
  246.  
  247. /**************************************************************************
  248.   The following three calls are used to allow applications to behave
  249.   courteously when a user interaction such as a dialog box is needed. 
  250. **************************************************************************/
  251.  
  252. typedef SInt8                             AEInteractAllowed;
  253. enum {
  254.     kAEInteractWithSelf            = 0,
  255.     kAEInteractWithLocal        = 1,
  256.     kAEInteractWithAll            = 2
  257. };
  258.  
  259. EXTERN_API( OSErr )
  260. AEGetInteractionAllowed            (AEInteractAllowed *    level)                                THREEWORDINLINE(0x303C, 0x021D, 0xA816);
  261.  
  262. EXTERN_API( OSErr )
  263. AESetInteractionAllowed            (AEInteractAllowed         level)                                THREEWORDINLINE(0x303C, 0x011E, 0xA816);
  264.  
  265. EXTERN_API( OSErr )
  266. AEInteractWithUser                (long                     timeOutInTicks,
  267.                                  NMRecPtr                 nmReqPtr,
  268.                                  AEIdleUPP                 idleProc)                            THREEWORDINLINE(0x303C, 0x061C, 0xA816);
  269.  
  270.  
  271. /**************************************************************************
  272.   These calls are used to set up and modify the event dispatch table.
  273. **************************************************************************/
  274. EXTERN_API( OSErr )
  275. AEInstallEventHandler            (AEEventClass             theAEEventClass,
  276.                                  AEEventID                 theAEEventID,
  277.                                  AEEventHandlerUPP         handler,
  278.                                  long                     handlerRefcon,
  279.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x091F, 0xA816);
  280.  
  281. EXTERN_API( OSErr )
  282. AERemoveEventHandler            (AEEventClass             theAEEventClass,
  283.                                  AEEventID                 theAEEventID,
  284.                                  AEEventHandlerUPP         handler,
  285.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0720, 0xA816);
  286.  
  287. EXTERN_API( OSErr )
  288. AEGetEventHandler                (AEEventClass             theAEEventClass,
  289.                                  AEEventID                 theAEEventID,
  290.                                  AEEventHandlerUPP *    handler,
  291.                                  long *                    handlerRefcon,
  292.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0921, 0xA816);
  293.  
  294.  
  295. /**************************************************************************
  296.  The following four calls are available for applications which need more
  297.  sophisticated control over when and how events are processed. Applications
  298.  which implement multi-session servers or which implement their own
  299.  internal event queueing will probably be the major clients of these
  300.  routines. They can be called from within a handler to prevent the AEM from
  301.  disposing of the AppleEvent when the handler returns. They can be used to
  302.  asynchronously process the event (as MacApp does).
  303. **************************************************************************/
  304. EXTERN_API( OSErr )
  305. AESuspendTheCurrentEvent        (const AppleEvent *        theAppleEvent)                        THREEWORDINLINE(0x303C, 0x022B, 0xA816);
  306.  
  307. /* 
  308.  Note: The following routine tells the AppleEvent manager that processing
  309.  is either about to resume or has been completed on a previously suspended
  310.  event. The procPtr passed in as the dispatcher parameter will be called to
  311.  attempt to redispatch the event. Several constants for the dispatcher
  312.  parameter allow special behavior. They are:
  313.       - kAEUseStandardDispatch means redispatch as if the event was just
  314.       received, using the standard AppleEvent dispatch mechanism.
  315.       - kAENoDispatch means ignore the parameter.
  316.          Use this in the case where the event has been handled and no
  317.       redispatch is needed.
  318.       - non nil means call the routine which the dispatcher points to.
  319. */
  320. /* Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch */
  321. enum {
  322.     kAEDoNotIgnoreHandler        = 0x00000000,
  323.     kAEIgnoreAppPhacHandler        = 0x00000001,                    /* available only in vers 1.0.1 and greater */
  324.     kAEIgnoreAppEventHandler    = 0x00000002,                    /* available only in vers 1.0.1 and greater */
  325.     kAEIgnoreSysPhacHandler        = 0x00000004,                    /* available only in vers 1.0.1 and greater */
  326.     kAEIgnoreSysEventHandler    = 0x00000008,                    /* available only in vers 1.0.1 and greater */
  327.     kAEIngoreBuiltInEventHandler = 0x00000010,                    /* available only in vers 1.0.1 and greater */
  328.     kAEDontDisposeOnResume        = (long)0x80000000                /* available only in vers 1.0.1 and greater */
  329. };
  330.  
  331. /* Constants for AEResumeTheCurrentEvent */
  332. enum {
  333.     kAENoDispatch                = 0,                            /* dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch */
  334.     kAEUseStandardDispatch        = (long)0xFFFFFFFF                /* table, or one of these two constants */
  335. };
  336.  
  337. EXTERN_API( OSErr )
  338. AEResumeTheCurrentEvent            (const AppleEvent *        theAppleEvent,
  339.                                  const AppleEvent *        reply,
  340.                                  AEEventHandlerUPP         dispatcher,
  341.                                  long                     handlerRefcon)                        THREEWORDINLINE(0x303C, 0x0818, 0xA816);
  342.  
  343. EXTERN_API( OSErr )
  344. AEGetTheCurrentEvent            (AppleEvent *            theAppleEvent)                        THREEWORDINLINE(0x303C, 0x021A, 0xA816);
  345.  
  346. EXTERN_API( OSErr )
  347. AESetTheCurrentEvent            (const AppleEvent *        theAppleEvent)                        THREEWORDINLINE(0x303C, 0x022C, 0xA816);
  348.  
  349.  
  350. /**************************************************************************
  351.   These calls are used to set up and modify special hooks into the
  352.   AppleEvent manager.
  353. **************************************************************************/
  354. EXTERN_API( OSErr )
  355. AEInstallSpecialHandler            (AEKeyword                 functionClass,
  356.                                  AEEventHandlerUPP         handler,
  357.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0500, 0xA816);
  358.  
  359. EXTERN_API( OSErr )
  360. AERemoveSpecialHandler            (AEKeyword                 functionClass,
  361.                                  AEEventHandlerUPP         handler,
  362.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0501, 0xA816);
  363.  
  364. EXTERN_API( OSErr )
  365. AEGetSpecialHandler                (AEKeyword                 functionClass,
  366.                                  AEEventHandlerUPP *    handler,
  367.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x052D, 0xA816);
  368.  
  369.  
  370. /**************************************************************************
  371.   This call was added in version 1.0.1. If called with the keyword
  372.   keyAERecorderCount ('recr'), the number of recorders that are
  373.   currently active is returned in 'result'
  374.   (available only in vers 1.0.1 and greater).
  375. **************************************************************************/
  376. EXTERN_API( OSErr )
  377. AEManagerInfo                    (AEKeyword                 keyWord,
  378.                                  long *                    result)                                THREEWORDINLINE(0x303C, 0x0441, 0xA816);
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. #if PRAGMA_STRUCT_ALIGN
  386.     #pragma options align=reset
  387. #elif PRAGMA_STRUCT_PACKPUSH
  388.     #pragma pack(pop)
  389. #elif PRAGMA_STRUCT_PACK
  390.     #pragma pack()
  391. #endif
  392.  
  393. #ifdef PRAGMA_IMPORT_OFF
  394. #pragma import off
  395. #elif PRAGMA_IMPORT
  396. #pragma import reset
  397. #endif
  398.  
  399. #ifdef __cplusplus
  400. }
  401. #endif
  402.  
  403. #endif /* __APPLEEVENTS__ */
  404.  
  405.