home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-28 | 3.0 KB | 103 lines | [TEXT/KAHL] |
- // Bolo code (C) Stuart Cheshire <cheshire@cs.stanford.edu> 1987-1995.
- // All rights reserved. This code is owned by Stuart Cheshire and is donated
- // free of charge for non-commercial use. You may not use this code in any
- // product sold for commercial profit, except shareware priced at $25 or less.
-
- #include "BrainFrame.h"
- #include "BF_Main.h"
- #include "BF_Utils.h"
- #include "BF_AppleEvents.h"
- #include "BF_ResourceIDs.h"
-
- local OSErr MoreParameters(const AppleEvent *e)
- {
- DescType returnedType;
- Size actualSize;
- OSErr err = AEGetAttributePtr(e, keyMissedKeywordAttr, typeWildCard,
- &returnedType, NULL, 0, &actualSize);
- if (err != errAEDescNotFound) return (errAEParamMissed); else return(noErr);
- }
-
- local pascal OSErr MyHandleOApp(const AppleEvent *e, AppleEvent *r, long Refcon)
- {
- OSErr err = MoreParameters(e);
- r;//Unused
- Refcon;//Unused
- // if (!err) DebugStr("\pMyHandleOApp");
- return(err);
- }
-
- local pascal OSErr MyHandleODoc(const AppleEvent *e, AppleEvent *r, long Refcon)
- {
- FSSpec myFSS;
- AEDescList docList;
- OSErr myErr;
- long index, itemsInList;
- Size actualSize;
- AEKeyword keywd;
- DescType returnedType;
-
- r;//Unused
- Refcon;//Unused
- //DebugStr("\pMyHandleODoc");
-
- myErr = AEGetParamDesc(e, keyDirectObject, typeAEList, &docList);
- if (myErr) return(myErr);
-
- myErr = MoreParameters(e);
- if (myErr) { AEDisposeDesc(&docList); return(myErr); }
-
- myErr = AECountItems(&docList, &itemsInList);
- if (myErr) { AEDisposeDesc(&docList); return(myErr); }
-
- for (index = 1; index<=itemsInList; index++)
- {
- //FInfo fndrInfo;
- myErr = AEGetNthPtr(&docList, index, typeFSS, &keywd, &returnedType, &myFSS,
- sizeof(myFSS), &actualSize);
- //if (!myErr && !FSpGetFInfo(&myFSS, &fndrInfo)) process_file(&myFSS, fndrInfo.fdType);
- }
- AEDisposeDesc(&docList);
- return(noErr);
- }
-
- local pascal OSErr MyHandlePDoc(const AppleEvent *e, AppleEvent *r, long Refcon)
- {
- e;//Unused
- r;//Unused
- Refcon;//Unused
- //DebugStr("\pMyHandlePDoc");
- MyStopAlert(alert_cannot_print);
- return(errAENoUserInteraction);
- }
-
- #define kUserCanceled 1 // What is this supposed to be?
-
- local pascal OSErr MyHandleQuit(const AppleEvent *e, AppleEvent *r, long Refcon)
- {
- OSErr err = MoreParameters(e);
- r;//Unused
- Refcon;//Unused
- //DebugStr("\pMyHandleQuit");
- if (err) return(err);
- //if (quitalert()) err = kUserCanceled;
- //else
- quitting = TRUE;
- return(err);
- }
-
- export void AppleEventInits(void)
- {
- EventRecord e;
- if (!hasAppleEvents) return;
- AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, MyHandleOApp, 0, FALSE);
- AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, MyHandleODoc, 0, FALSE);
- AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, MyHandlePDoc, 0, FALSE);
- AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, MyHandleQuit, 0, FALSE);
-
- // Get the first event, which should be an OApp or an ODoc,
- // possibly telling us which preferences file to use.
- WaitNextEvent(highLevelEventMask, &e, 0, NULL);
- if (e.what == kHighLevelEvent) AEProcessAppleEvent(&e);
- }
-