Ignore:
Timestamp:
03/02/03 19:53:27 (22 years ago)
Author:
Nicholas Riley
Message:

PSAlarm.m: Fixed logic bug with invalid date/time combination. Added
repeating indicator to -description. Fixed plist archiving to
properly handle repeating alarms which expire while the app is quit
(1).

PSAlarmAlertController.m: Restore some debugging.

PSPowerManager.m: Properly return pmuReference (fixes compiler
warning, and 2).

Read Me.rtfd: Fixed some wording.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSAlarm.m

    r103 r105  
    184184    dateTime = [NSCalendarDate dateWithDate: date atTime: time];
    185185    if (dateTime == nil) {
    186         [self _beInvalid: @"Please specify a reasonable date and time."];
     186        [self _beInvalid: @"Please specify a reasonable date and time."]; return;
    187187    }
    188188    [self setForDateAtTime: dateTime];
     
    418418- (NSString *)description;
    419419{
    420     return [NSString stringWithFormat: @"%@: type %@ date %@ interval %.1f%@",
     420    return [NSString stringWithFormat: @"%@: type %@ date %@ interval %.1f%@%@",
    421421        [super description], [self _alarmTypeString], alarmDate, alarmInterval,
     422        (repeating ? @" repeating" : @""),
    422423        (alarmType == PSAlarmInvalid ?
    423424         [NSString stringWithFormat: @"\ninvalid message: %@", invalidMessage]
     
    437438        case PSAlarmSet:
    438439            [dict setObject: [NSNumber numberWithDouble: [alarmDate timeIntervalSinceReferenceDate]] forKey: PLAlarmDate];
    439             break;
    440440        case PSAlarmSnooze:
    441441        case PSAlarmInterval:
    442442        case PSAlarmExpired:
    443             [dict setObject: [NSNumber numberWithDouble: alarmInterval] forKey: PLAlarmInterval];
    444             [dict setObject: [NSNumber numberWithBool: repeating] forKey: PLAlarmRepeating];
    445443            break;
    446444        default:
    447445            NSAssert1(NO, NSLocalizedString(@"Can't save alarm type %@", "Assertion for invalid PSAlarm type on string; %@ replaced with alarm type string"), [self _alarmTypeString]);
    448446            break;
     447    }
     448    if ((alarmType != PSAlarmSet || repeating) && alarmType != PSAlarmDate) {
     449        [dict setObject: [NSNumber numberWithBool: repeating] forKey: PLAlarmRepeating];
     450        [dict setObject: [NSNumber numberWithDouble: alarmInterval] forKey: PLAlarmInterval];
    449451    }
    450452    if (snoozeInterval != 0)
     
    474476            case PSAlarmInterval:
    475477            case PSAlarmExpired:
    476                 alarmInterval = [[dict objectForRequiredKey: PLAlarmInterval] doubleValue];
    477                 repeating = [[dict objectForRequiredKey: PLAlarmRepeating] boolValue];
    478478                break;
    479479            default:
     
    481481                break;
    482482        }
     483        repeating = [[dict objectForKey: PLAlarmRepeating] boolValue];
     484        if ((alarmType != PSAlarmSet || repeating) && alarmType != PSAlarmDate)
     485            alarmInterval = [[dict objectForRequiredKey: PLAlarmInterval] doubleValue];
    483486        snoozeInterval = [[dict objectForKey: PLAlarmSnoozeInterval] doubleValue];
    484487        [self setMessage: [dict objectForRequiredKey: PLAlarmMessage]];
     
    488491        if (alarmType == PSAlarmSet) {
    489492            alarmType = PSAlarmDate;
    490             [self setTimer];
     493            // don't want to put this logic in setTimer or isValid because it can cause invalid alarms to be set (consider when someone clicks the "repeat" checkbox, then switches to a [nonrepeating, by design] date alarm, and enters a date that has passed: we do -not- want the alarm to magically morph into a repeating interval alarm)
     494            if (![self setTimer] && [self isRepeating]) {
     495                alarmType = PSAlarmInterval;
     496                [self setInterval: [[dict objectForRequiredKey: PLAlarmInterval] doubleValue]];
     497                [self setTimer];
     498            }
    491499        }
    492500        if (alarmType == PSAlarmExpired) {
Note: See TracChangeset for help on using the changeset viewer.