home *** CD-ROM | disk | FTP | other *** search
- /* NAME:
- TM Task.c
-
- WRITTEN BY:
- Dair Grant
-
- DESCRIPTION:
- This file contains a code resource to be installed as a Time Manager
- task.
-
- NOTES:
- We fire every 10 seconds, and install a Notification Manager request
- that plays a sound.
-
- ___________________________________________________________________________
- */
- //=============================================================================
- // Include files
- //-----------------------------------------------------------------------------
- #include <Gestalt.h>
- #include <Notification.h>
- #include <Timer.h>
- #include "A4Stuff.h"
- #include "SetupA4.h"
- #include "MC Constants.h"
- #include "MC AddrsTable.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // Global Variables
- //-----------------------------------------------------------------------------
- TMTask *gTheTMTask;
- NMRec gTheNMRec;
- Boolean gAlreadyRan = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // Private function prototypes
- //-----------------------------------------------------------------------------
- pascal void main(void);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // main : Entry point to our code resource.
- //-----------------------------------------------------------------------------
- // Note : We install a Notification Manager request which plays the
- // sound, and reschedule ourselves for 10 seconds from now.
- //-----------------------------------------------------------------------------
- pascal void main(void)
- { long oldA4;
- MCAddressTable *theAddressTable;
- OSErr theErr;
-
-
-
- // Set up A4
- #ifndef powerc
- oldA4 = SetCurrentA4();
- #endif
-
-
-
- // If we've not already been called, call the Gestalt selector to get
- // the address of our task record, and create our Notification
- // Manager record.
- if (!gAlreadyRan)
- {
- // Call gestalt and get the address of our task
- Gestalt(kMacCoughAddressTable, (long *) &theAddressTable);
- gTheTMTask = (TMTask *) ((long) theAddressTable->theTable[kTimeTask]);
-
-
- // Make up a Notification Manager request
- gTheNMRec.qType = nmType; // NM request type
- gTheNMRec.nmMark = 0; // No mark in the menu
- gTheNMRec.nmIcon = nil; // No icon in the menu
- gTheNMRec.nmSound = theAddressTable->theSound; // Play this sound
- gTheNMRec.nmStr = nil; // Don't show a dialog
- gTheNMRec.nmResp = (NMUPP) -1; // Remove the note afterwards
-
-
- // This code doesn't need to be executed again
- gAlreadyRan = true;
- }
-
-
-
- // Install the Notification Manager request (which plays
- // the sound) and requeue ourselves for 10 seconds from now.
- theErr = NMInstall(&gTheNMRec);
- PrimeTime((QElemPtr) gTheTMTask, 10000);
-
-
-
- // Restore A4 and return
- #ifndef powerc
- SetA4(oldA4);
- #endif
- }
-
-