Index: trunk/Cocoa/Pester/Source/PSPowerManager.m
===================================================================
--- trunk/Cocoa/Pester/Source/PSPowerManager.m	(revision 118)
+++ trunk/Cocoa/Pester/Source/PSPowerManager.m	(revision 119)
@@ -8,17 +8,8 @@
 
 #import "PSPowerManager.h"
-#import "wakein.h"
 
 #import <IOKit/pwr_mgt/IOPMLib.h>
 #import <IOKit/IOMessage.h>
 #import <CoreFoundation/CoreFoundation.h>
-
-// MoreIsBetter interfaces
-#include "MoreUNIX.h"
-#include "MoreSecurity.h"
-#include "MoreCFQ.h"
-
-// exceptions
-NSString * const PSPowerManagerException = @"PSPowerManagerException";
 
 /*
@@ -61,12 +52,5 @@
 // for superusers
 
-// njr 2003.03.12: both seem to be interchangeable now, and the sleep time is
-// no longer settable as non-root.
-
-#ifdef WAKEIN
-#define PMU_MAGIC_PASSWORD	0x0101BEEF
-#else
 #define PMU_MAGIC_PASSWORD	0x0101FACE
-#endif
 
 /* ==========================================
@@ -104,5 +88,4 @@
     kern_return_t kr = kIOReturnNoMemory;
     CFDataRef data;
-    CFMutableDictionaryRef dict = 0;
 
     data = CFDataCreate(kCFAllocatorDefault, bytes, size);
@@ -110,11 +93,6 @@
     [(NSData *)data autorelease];
 
-    dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-    NSCAssert(data != NULL, @"writeDataProperty: CFDictionaryCreateMutable failed");
-    [(NSMutableDictionary *)dict autorelease];
-
-    CFDictionarySetValue(dict, name, data);
-    kr = IOConnectSetCFProperties(handle, dict);
-    NSCAssert1(kr == KERN_SUCCESS, @"writeDataProperty: IOConnectSetCFProperties returned an error of type %08lx", (unsigned long)kr);
+    kr = IOConnectSetCFProperty(handle, name, data);
+    NSCAssert1(kr == KERN_SUCCESS, @"writeDataProperty: IOConnectSetCFProperty returned an error of type %08lx", (unsigned long)kr);
 }
 
@@ -189,9 +167,4 @@
     if (pmuReference == NULL) return NO;
     closePMUComPort(pmuReference);
-    NS_DURING
-        [self authorize];
-    NS_HANDLER
-        return NO; // XXX display error?
-    NS_ENDHANDLER
     return YES;
 }
@@ -220,58 +193,9 @@
 }
 
-+ (void)_execWakeToolWithRequestDictionary:(NSDictionary *)request;
-{
-    AuthorizationRef auth = NULL;
-    NSException *exception = NULL;
-
-    NS_DURING
-        CFURLRef tool = NULL;
-        Boolean toolFound;
-        OSStatus err = MoreSecCopyHelperToolURLAndCheckBundled(
-                                                      CFBundleGetMainBundle(), CFSTR("wakeinTemplate"), kApplicationSupportFolderType, CFSTR("Pester"), CFSTR("wakein"), &tool, &toolFound);
-        if (err != noErr) [NSException raise: PSPowerManagerException format: NSLocalizedString(@"Can't set up timed wake from sleep: unable to copy helper tool to Application Support folder (error %u)", "MoreSecCopyHelperToolURLAndCheckBundled failure"), err];
-        [(NSURL *)tool autorelease];
-
-        // if we've found the tool (and it's setuid root), still get an AuthorizationRef, but don't bother to obtain additional rights
-        err = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, toolFound ? kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed : kAuthorizationFlagDefaults, &auth);
-        if (err != noErr) [NSException raise: PSPowerManagerException format: NSLocalizedString(@"Can't set up timed wake from sleep: AuthorizationCreate failed (error %u)", "AuthorizationCreate failure"), err];
-
-        NSDictionary *response;
-        err = MoreSecExecuteRequestInHelperTool(tool, auth, (CFDictionaryRef)request, (CFDictionaryRef *)&response);
-        [response autorelease];
-        if (err != noErr) [NSException raise: PSPowerManagerException format: NSLocalizedString(@"Can't set up timed wake from sleep: can't obtain response from helper tool (error %u)", "MoreSecExecuteRequestInHelperTool failure"), err];
-
-        NSLog(@"%@", response);
-
-        NSString *wakeinException = [response objectForKey: kPesterWakeException];
-        if (wakeinException != nil) [NSException raise: PSPowerManagerException format: NSLocalizedString(@"Can't set up timed wake from sleep: helper tool reported the error '%@'", "kPesterWakeException"), wakeinException];
-
-        err = MoreSecGetErrorFromResponse((CFDictionaryRef)response);
-        if (err != noErr) [NSException raise: PSPowerManagerException format: NSLocalizedString(@"Can't set up timed wake from sleep: helper tool reported an error of type %u", "MoreSecGetErrorFromResponse"), err];
-        
-    NS_HANDLER
-        exception = localException;
-    NS_ENDHANDLER
-
-    if (auth != NULL) AuthorizationFree(auth, kAuthorizationFlagDestroyRights);
-    if (exception != NULL) [exception raise];
-}
-
-+ (void)authorize;
-{
-    [self _execWakeToolWithRequestDictionary: [NSDictionary dictionary]];
-}
-
 + (void)setWakeInterval:(unsigned long)wakeInterval;
 {
-#ifdef WAKEIN
     io_service_t pmuReference = [self _pmuReference];
-    NSLog(@"writePMUProperty[%u] 0x%lX AutoWake = %lu", pmuReference, PMU_MAGIC_PASSWORD, wakeInterval);
     writePMUProperty(pmuReference, CFSTR("AutoWake"), (unsigned long *)&wakeInterval, sizeof(wakeInterval));
-
     closePMUComPort(pmuReference);
-#else
-    [self _execWakeToolWithRequestDictionary: [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedLong: wakeInterval] forKey: kPesterWakeTime]];
-#endif
 }
 
@@ -288,5 +212,5 @@
         if (!override) {
             NSDate *wakeTime = [self wakeTime];
-            override = (wakeTime == nil || [wakeTime compare: time] == NSOrderedDescending);
+            override = (wakeTime == nil || [wakeTime compare: time] == NSOrderedAscending);
         }
     }
