All pastes #803294 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-12-01 01:34 UTC
rendered paste body
#import <Foundation/Foundation.h>
#import <IOKit/pwr_mgt/IOPMLib.h>

int main (int argc, const char * argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int res;
	
    NSCalendarDate *now = [NSCalendarDate calendarDate];

    NSCalendarDate *tommorrow =
            [NSCalendarDate
                  dateWithYear:[now yearOfCommonEra]
                  month: [now monthOfYear]
//                  day:[now dayOfMonth]+1
                  day:[now dayOfMonth]
                  hour:22
		          minute:0
				  second:30
                  timeZone: [now timeZone]
             ];
	NSLog(@"Now:%@", now);	
	NSLog(@"tommorrow:%@", tommorrow);	
    NSLog(@"tommorrow:%f", [tommorrow timeIntervalSinceReferenceDate]);
	
//    res = IOPMSchedulePowerEvent ((CFDateRef)tommorrow,CFSTR("Jerry"), CFSTR(kIOPMAutoWakeOrPowerOn));
    res = IOPMCancelScheduledPowerEvent ((CFDateRef)tommorrow,CFSTR("Jerry"), CFSTR(kIOPMAutoWakeOrPowerOn));

   if(res == kIOReturnSuccess)
   {
     printf("Daily Wakeup Call successfully installed\n");
   }
   else 
   {
     printf("Daily Wakeup Call failed to install,errcode:%x\n",res);
   }	

    [pool release];
    return 0;
}