Register for some notification and handle them as followsUnregister with SysNotifyUnregister() when no more neededYou can use a Feature (see How to store a permanent value... ) to store the program start time
/*********************************************************************************************/
static void RegisterForNotifications()
{ 
UInt16   cardNo=0; 
UInt32   romVersion=0; 
LocalID dbID=0;
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);  
if(romVersion <>
          return;  
if(SysCurAppDatabase(&cardNo, &dbID)!=0)   
         return; 
// Register the Notification you need 
SysNotifyRegister(cardNo, dbID, sysNotifyEarlyWakeupEvent, NULL, sysNotifyNormalPriority, 0); 
SysNotifyRegister(cardNo, dbID, sysNotifyLateWakeupEvent, NULL, sysNotifyNormalPriority, 0); 
SysNotifyRegister(cardNo, dbID, sysNotifySleepRequestEvent, NULL, sysNotifyNormalPriority, 0);
}
/****************************************************************************************/
static void HandleNotifications(SysNotifyParamType *np)
{  
if(np->notifyType==sysNotifyEarlyWakeupEvent)  
{   
// Do something  
} 
else if(np->notifyType==sysNotifyLateWakeupEvent)  
{   
// Do something  
} 
else if(np->notifyType==sysNotifySleepRequestEvent)  
{  
 // Do something  
}
}
/***************************************************************************************/
UInt32 PilotMain(UInt16 cmd,void *cmdPBP,UInt16 launchFlags)
{  
          switch(cmd)  
         {   
               case sysAppLaunchCmdSystemReset:   
               case sysAppLaunchCmdSyncNotify:    
                            RegisterForNotifications();
                            break;
               case sysAppLaunchCmdNotify:   
               case sysNotifySleepRequestEvent:    
                           HandleNotifications((SysNotifyParamType *)cmdPBP);    
                           break;
              case sysAppLaunchCmdNormalLaunch:    
                     ... Normal code ...
}
Monday, August 20, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment