mirror of
https://github.com/aaronsgiles/uuUndo.git
synced 2024-11-22 01:32:02 +00:00
1 line
7.9 KiB
C
1 line
7.9 KiB
C
|
/******************************************************************************
**
** Project Name: DropShell
** File Name: DSAppleEvents.c
**
** Description: Generic AppleEvent handling routines
**
** This is the set of routines for handling the required Apple events.
** You should NEVER have to modify this file!!!
** Simply add code in DSUserProcs to the routines called by these.
**
*******************************************************************************
** A U T H O R I D E N T I T Y
*******************************************************************************
**
** Initials Name
** -------- -----------------------------------------------
** LDR Leonard Rosenthol
** MTC Marshall Clow
** SCS Stephan Somogyi
**
*******************************************************************************
** R E V I S I O N H I S T O R Y
*******************************************************************************
**
** Date Time Author Description
** -------- ----- ------ ---------------------------------------------
** 11/24/91 LDR Added a handler for 'pdoc' as per DTS recommendation
** This caused some reorg & userProc routine changes
** I also created a new common AEVT doc extractor
** Cleaned up error handling by adding FailErr
** Cleaned up the placement of braces
** Added the passing of a userDataHandle to the odoc/pdoc routines
** 10/29/91 SCS Changes for THINK C 5
** 10/28/91 LDR Officially renamed DropShell (from QuickShell)
** Added a bunch of comments for clarification
** 10/06/91 00:02 MTC Converted to MPW C
** 04/09/91 00:02 LDR Added to Projector
**
******************************************************************************/
#include "DSGlobals.h"
#include "DSUserProcs.h"
#include "DSAppleEvents.h"
/*
This routine does all initialization for AEM, including the
creation and then population of the dispatch table.
*/
#pragma segment Initialize
pascal void InitAEVTStuff () {
OSErr aevtErr;
aevtErr = noErr;
if ( aevtErr == noErr )
aevtErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenApplication,
NewAEEventHandlerProc((ProcPtr)HandleOAPP), 0, false );
if ( aevtErr == noErr )
aevtErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenDocuments,
NewAEEventHandlerProc((ProcPtr)HandleODOC), 0, false );
if ( aevtErr == noErr )
aevtErr = AEInstallEventHandler ( kCoreEventClass, kAEPrintDocuments,
NewAEEventHandlerProc((ProcPtr)HandlePDOC), 0, false );
if ( aevtErr == noErr )
aevtErr = AEInstallEventHandler ( kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerProc((ProcPtr)HandleQuit), 0, false );
if ( aevtErr == noErr )
InstallOtherEvents ();
if ( aevtErr != noErr )
; // report an error if you are so included
}
/*
This routine is a utility routine for checking that all required
parameters in the Apple event have been used.
*/
#pragma segment Main
OSErr GotRequiredParams ( AppleEvent *theAppleEvent ) {
DescType typeCode;
Size actualSize;
OSErr retErr, err;
err = AEGetAttributePtr ( theAppleEvent, keyMissedKeywordAttr,
typeWildCard, &typeCode, NULL, 0, &actualSize );
if ( err == errAEDescNotFound ) // we got all the required params: all is ok
retErr = noErr;
else if ( err == noErr )
retErr = errAEEventNotHandled;
else
retErr = err;
return retErr;
}
/*
This is another routine useful for showing debugging info.
It calls the ErrorAlert routine from DSUtils to put up the
error message.
*/
void FailErr(OSErr err) {
if (err != noErr)
ErrorAlert(kErrStringID, kAEVTErr, err);
}
/*
This routine is the handler for the oapp (Open Application) event.
It first checks the number of parameters to make sure we got them all
(even though we don't want any) and then calls the OpenApp userProc in QSUserProcs.
Finally it checks to see if the caller wanted a reply & sends one, setting any error.
*/
#pragma segment Main
pascal OSErr HandleOAPP ( AppleEvent *theAppleEvent, AppleEvent *reply, lon
|