[24] | 1 | //
|
---|
| 2 | // PSAlarm.h
|
---|
| 3 | // Pester
|
---|
| 4 | //
|
---|
| 5 | // Created by Nicholas Riley on Wed Oct 09 2002.
|
---|
| 6 | // Copyright (c) 2002 Nicholas Riley. All rights reserved.
|
---|
| 7 | //
|
---|
| 8 |
|
---|
| 9 | #import <Foundation/Foundation.h>
|
---|
[53] | 10 | #import "PSPropertyListSerialization.h"
|
---|
[24] | 11 |
|
---|
| 12 | typedef enum {
|
---|
[53] | 13 | PSAlarmInvalid, // incorrectly specified
|
---|
| 14 | PSAlarmInterval, // interval specified (possibly repeating)
|
---|
| 15 | PSAlarmDate, // date specified
|
---|
| 16 | PSAlarmSet, // pending, timer set
|
---|
| 17 | PSAlarmSnooze, // expired alarm with snooze interval set (possibly repeating)
|
---|
| 18 | PSAlarmExpired // expired alarm (possibly repeating)
|
---|
[24] | 19 | } PSAlarmType;
|
---|
| 20 |
|
---|
[26] | 21 | extern NSString * const PSAlarmTimerSetNotification;
|
---|
| 22 | extern NSString * const PSAlarmTimerExpiredNotification;
|
---|
[53] | 23 | extern NSString * const PSAlarmDiedNotification;
|
---|
[26] | 24 |
|
---|
[61] | 25 | @class PSAlert, PSAlerts, PSTimer;
|
---|
[34] | 26 |
|
---|
[53] | 27 | @interface PSAlarm : NSObject <NSCoding, PSPropertyListSerialization> {
|
---|
| 28 | PSAlarmType alarmType; // changes during lifetime of alarm; more like a state
|
---|
[24] | 29 | NSCalendarDate *alarmDate;
|
---|
| 30 | NSTimeInterval alarmInterval;
|
---|
[53] | 31 | NSTimeInterval snoozeInterval;
|
---|
| 32 | NSTimeInterval timeRemaining;
|
---|
[24] | 33 | NSString *alarmMessage;
|
---|
| 34 | NSString *invalidMessage;
|
---|
[61] | 35 | PSTimer *timer;
|
---|
[53] | 36 | PSAlerts *alerts;
|
---|
| 37 | BOOL repeating;
|
---|
[24] | 38 | }
|
---|
| 39 |
|
---|
| 40 | - (void)setInterval:(NSTimeInterval)anInterval;
|
---|
[26] | 41 | - (void)setForDateAtTime:(NSCalendarDate *)dateTime;
|
---|
[24] | 42 | - (void)setForDate:(NSDate *)date atTime:(NSDate *)time;
|
---|
| 43 | - (void)setMessage:(NSString *)aMessage;
|
---|
[53] | 44 | - (void)setAlerts:(PSAlerts *)theAlerts;
|
---|
| 45 | - (void)setRepeating:(BOOL)isRepeating;
|
---|
| 46 | - (void)setSnoozeInterval:(NSTimeInterval)anInterval;
|
---|
[61] | 47 | - (void)setWakeUp:(BOOL)doWake;
|
---|
[24] | 48 |
|
---|
[28] | 49 | - (NSCalendarDate *)date;
|
---|
[608] | 50 | - (NSDate *)midnightOnDate;
|
---|
[366] | 51 | - (NSDate *)time;
|
---|
[608] | 52 | - (int)daysFromToday;
|
---|
[24] | 53 | - (NSTimeInterval)interval;
|
---|
[53] | 54 | - (NSTimeInterval)timeRemaining;
|
---|
[26] | 55 | - (NSString *)message;
|
---|
[53] | 56 | - (PSAlerts *)alerts;
|
---|
| 57 | - (BOOL)isRepeating;
|
---|
| 58 | - (NSTimeInterval)snoozeInterval; // most recent interval (nonzero return does not indicate alarm is snoozing or set to snooze)
|
---|
[24] | 59 |
|
---|
[43] | 60 | - (NSString *)dateString;
|
---|
[28] | 61 | - (NSString *)shortDateString;
|
---|
| 62 | - (NSString *)timeString;
|
---|
[53] | 63 | - (NSString *)dateTimeString; // current or next alarm time
|
---|
| 64 | - (NSString *)nextDateTimeString; // next alarm time
|
---|
| 65 | - (NSString *)intervalString;
|
---|
[28] | 66 | - (NSString *)timeRemainingString;
|
---|
| 67 |
|
---|
[24] | 68 | - (BOOL)isValid;
|
---|
| 69 | - (NSString *)invalidMessage;
|
---|
| 70 |
|
---|
[53] | 71 | - (NSAttributedString *)prettyDescription;
|
---|
| 72 |
|
---|
[51] | 73 | - (NSComparisonResult)compareDate:(PSAlarm *)otherAlarm;
|
---|
| 74 | - (NSComparisonResult)compareMessage:(PSAlarm *)otherAlarm;
|
---|
[28] | 75 |
|
---|
[53] | 76 | - (BOOL)setTimer; // or die, if expired and no snooze/repeat
|
---|
[51] | 77 | - (void)cancelTimer;
|
---|
[113] | 78 | - (void)resetTimer; // use after cancel, only effective on set alarms
|
---|
[26] | 79 |
|
---|
[366] | 80 | // 1.1 only, going away when we move to keyed archiving (or Core Data)
|
---|
[53] | 81 | - (NSDictionary *)propertyListRepresentation;
|
---|
| 82 | - (id)initWithPropertyList:(NSDictionary *)dict;
|
---|
| 83 |
|
---|
[24] | 84 | @end
|
---|