source: releases/Pester/1.1b7/Source/PSPowerManager.m@ 658

Last change on this file since 658 was 361, checked in by Nicholas Riley, 17 years ago

VERSION: Updated for 1.1b5.

English.lproj/InfoPlist.strings: Updated for 1.1b5.

English.lproj/MainMenu.nib: Change IB compatibility level to 10.4.
Disable controls which lead to unstable functionality in this version.
Added Sparkle support. Hook up removeMessageButton to
PSAlarmSetController for "-" fallback drawing.

English.lproj/Preferences.nib: Added Sparkle checkbox.

English.lproj/Read Me.nib: Leopard-ized with source list coloring,
highlight and removed focus ring (which caused artifacts anyway).

English.lproj/Snooze until.nib: Use new natural language date strings
and calendar button bezel style.

Info-Pester.plist: Updated for 1.1b5. Added Sparkle support.

NJRDateFormatter.m: Comment out debug logging on every keystroke.

PSAlarmSetController.[hm]: If "-" image exists (on Leopard), don't
draw it with text as well.

PSAlerts.m: Don't describe bounce alert (which is present for
backwards compatibility, but doesn't work yet in this version).

PSPowerManager.m: Temporarily disable; untested in this version.

Pester.xcodeproj: Change Development/Deployment to Debug/Release.
Link to Sparkle. STRIP_INSTALLED_PRODUCT=NO on release version for
now (eventually, can investigate using symbol files).

Read Me.rtfd: Updated for 1.1b5. Use real links. Clean up release
notes. Credit Sparkle and Date::Manip. Clean up styles so they look
better in the read me viewer. Fix Omni link.

Sparkle.diff: Changes to Sparkle, which is included as an external.
These aren't yet automatically applied.

Updates/Application icon.png: The icon converted to a PNG. This will
probably go away as it's too big.

Updates/release-notes.css: Release notes CSS based on the example that
comes with Sparkle.

Updates/release-notes.html: Dummy release notes file; nobody should
see this yet.

Updates/updates.xml: Initial Sparkle appcast file.

package-Pester.sh: Update for xcodebuild, Sparkle, etc. No longer
include source in download.

File size: 2.5 KB
Line 
1//
2// PSPowerManager.m
3// Pester
4//
5// Created by Nicholas Riley on Mon Dec 23 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "PSPowerManager.h"
10
11#import <IOKit/pwr_mgt/IOPMLib.h>
12#import <IOKit/IOMessage.h>
13
14@implementation PSPowerManager
15
16+ (BOOL)autoWakeSupported;
17{
18 // XXX imagine it's supported on all machines that support 10.4
19 return NO; // XXX temporary for 1.1b5
20}
21
22+ (void)setWakeTime:(NSDate *)time;
23{
24 IOPMSchedulePowerEvent((CFDateRef)time, (CFStringRef)[[NSBundle mainBundle] bundleIdentifier], CFSTR(kIOPMAutoWake));
25}
26
27+ (void)clearWakeTime;
28{
29 // XXX implement (IOPMCancelScheduledPowerEvent)
30}
31
32// modified from RegisterForSleep sample code
33
34- (void)_messageReceived:(natural_t)messageType withArgument:(void *)messageArgument;
35{
36 switch (messageType) {
37 case kIOMessageSystemWillSleep:
38 if ([delegate respondsToSelector: @selector(powerManagerWillDemandSleep:)]) {
39 [delegate powerManagerWillDemandSleep: self];
40 IOAllowPowerChange(root_port, (long)messageArgument);
41 }
42 break;
43 case kIOMessageCanSystemSleep:
44 if ([delegate respondsToSelector: @selector(powerManagerShouldIdleSleep:)]) {
45 if ([delegate powerManagerShouldIdleSleep: self]) {
46 IOAllowPowerChange(root_port, (long)messageArgument);
47 } else {
48 IOCancelPowerChange(root_port, (long)messageArgument);
49 }
50 }
51 break;
52 case kIOMessageSystemHasPoweredOn:
53 if ([delegate respondsToSelector: @selector(powerManagerDidWake:)])
54 [delegate powerManagerDidWake: self];
55 break;
56 }
57}
58
59void
60powerCallback(void *refCon, io_service_t service, natural_t messageType, void *messageArgument)
61{
62 [(PSPowerManager *)refCon _messageReceived: messageType withArgument: messageArgument];
63}
64
65- (id)initWithDelegate:(id)aDelegate;
66{
67 if ( (self = [super init]) != nil) {
68 IONotificationPortRef notificationPort;
69
70 delegate = [aDelegate retain];
71 root_port = IORegisterForSystemPower(self, &notificationPort, powerCallback, &notifier);
72 NSAssert(root_port != 0, @"IORegisterForSystemPower failed");
73
74 CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notificationPort), kCFRunLoopDefaultMode);
75 }
76 return self;
77}
78
79- (void)dealloc;
80{
81 IODeregisterForSystemPower(&notifier);
82 [delegate release];
83 [super dealloc];
84}
85
86@end
Note: See TracBrowser for help on using the repository browser.