iachandler.c

Go to the documentation of this file.
00001 
00002 /*  $Id: iachandler.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include "frontier.h"
00008 #include "standard.h"
00009 
00010 #include "iacinternal.h"
00011 
00012 
00013 /*
00014 7/16/94 dmb: Updated for Univeral Headers, PowerPC
00015 */
00016 
00017 
00018 
00019 
00020 Boolean IACinstallhandler (AEEventClass eventclass, AEEventID id, ProcPtr handler) {
00021     
00022     OSErr ec;
00023     
00024     #if TARGET_API_MAC_CARBON == 1
00025 
00026         ec = AEInstallEventHandler (eventclass, id, NewAEEventHandlerUPP ((AEEventHandlerProcPtr) handler), 0, false);
00027     
00028     #else
00029     
00030         ec = AEInstallEventHandler (eventclass, id, NewAEEventHandlerProc (handler), 0, false);
00031     
00032     #endif
00033     
00034     IACglobals.errorcode = ec;
00035     
00036     return (ec == noErr);
00037     } /*AEinstallhandler*/
00038 
00039 
00040 Boolean IACremovehandler (AEEventClass eventclass, AEEventID id, ProcPtr handler) {
00041 
00042     OSErr ec;
00043 
00044         #if TARGET_RT_MAC_CFM
00045             #if TARGET_API_MAC_CARBON == 1
00046                 AEEventHandlerUPP theHandler = NewAEEventHandlerUPP(handler);
00047                 ec = AERemoveEventHandler (eventclass, id, theHandler, false);
00048                 DisposeAEEventHandlerUPP(theHandler);
00049 
00050             #else   
00051             
00052                 long refcon;
00053                 
00054                 ec = AEGetEventHandler (eventclass, id, (AEEventHandlerUPP *) &handler, &refcon, false);
00055                 
00056                 if (ec == noErr)
00057                     ec = AERemoveEventHandler (eventclass, id, (AEEventHandlerUPP) handler, false);
00058             #endif//TARGET_API_MAC_CARBON == 0
00059         #else
00060 
00061         ec = AERemoveEventHandler (eventclass, id, (AEEventHandlerUPP) handler, false);
00062         
00063         #endif//end TARGET_RT_MAC_CFM
00064     
00065     IACglobals.errorcode = ec;
00066     
00067     return (ec == noErr);
00068     } /*IACremovehandler*/
00069 
00070 
00071 Boolean IAChandlerinstalled (OSType vclass, OSType vtoken, Boolean flsystemhandler) {
00072     
00073     /*
00074     return true if there's a handler installed with the indicated class and id.
00075     
00076     if flsystemhandler is true, we only consider system event handlers, if false 
00077     we only consider app-specific handlers.
00078     */
00079     
00080     OSErr ec;
00081     AEEventHandlerUPP handler;
00082     long refcon;
00083     
00084     ec = AEGetEventHandler (vclass, vtoken, &handler, &refcon, flsystemhandler);
00085     
00086     IACglobals.errorcode = ec;
00087     
00088     return (ec == noErr);
00089     } /*IAChandlerinstalled*/
00090 
00091 
00092 Boolean IACinstallcoercionhandler (DescType fromtype, DescType totype, ProcPtr handler) {
00093     
00094     OSErr ec;
00095     
00096     #if TARGET_API_MAC_CARBON == 1
00097     AECoercePtrUPP  theHandler = NewAECoercePtrUPP((AECoercePtrProcPtr) handler);
00098     ec = AEInstallCoercionHandler (fromtype, totype, (AECoercionHandlerUPP) theHandler, (long) 0, false, false);
00099     //should we delete this, my gut feeling is no, not until the app ends
00100     #else
00101     ec = AEInstallCoercionHandler (fromtype, totype, (AECoercionHandlerUPP) NewAECoercePtrProc (handler), (long) 0, false, false);
00102     #endif
00103         
00104     IACglobals.errorcode = ec;
00105 
00106     return (ec == noErr);
00107     } /*IACinstallcoercionhandler*/
00108 
00109 
00110 

Generated on Wed May 31 18:19:48 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6