]> err.no Git - sope/blob - sope-ical/NGiCal/iCalRecurrenceRule.h
added ievalrrule tool
[sope] / sope-ical / NGiCal / iCalRecurrenceRule.h
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGiCal_iCalRecurrenceRule_H_
23 #define __NGiCal_iCalRecurrenceRule_H_
24
25 #import <Foundation/NSObject.h>
26
27 /*
28   iCalRecurrenceRule
29  
30   Encapsulates a (probably complex) recurrence rule by offering
31   a high level API.
32  
33   NOTE: as of now, only a very limited subset of RFC2445 is implemented.
34         Please see the unit tests for what is covered.
35 */
36
37 typedef enum {
38   iCalRecurrenceFrequenceSecondly = 1,
39   iCalRecurrenceFrequenceMinutely = 2,
40   iCalRecurrenceFrequenceHourly   = 3,
41   iCalRecurrenceFrequenceDaily    = 4,
42   iCalRecurrenceFrequenceWeekly   = 5,
43   iCalRecurrenceFrequenceMonthly  = 6,
44   iCalRecurrenceFrequenceYearly   = 7,
45 } iCalRecurrenceFrequency;
46
47 typedef enum {
48   iCalWeekDayMonday    = 1,
49   iCalWeekDayTuesday   = 2,
50   iCalWeekDayWednesday = 4,
51   iCalWeekDayThursday  = 8,
52   iCalWeekDayFriday    = 16,
53   iCalWeekDaySaturday  = 32,
54   iCalWeekDaySunday    = 64,
55 } iCalWeekDay;
56
57 @class NSString, NSCalendarDate, NGCalendarDateRange;
58
59 @interface iCalRecurrenceRule : NSObject
60 {
61   iCalRecurrenceFrequency frequency;
62   int            interval;
63   unsigned       repeatCount;
64   NSCalendarDate *untilDate;
65   struct {
66     unsigned weekStart: 7;
67     unsigned mask:      7;
68   } byDay;
69
70   NSString       *rrule;
71 }
72
73 + (id)recurrenceRuleWithICalRepresentation:(NSString *)_iCalRep;
74 - (id)initWithString:(NSString *)_str;
75
76 /* accessors */
77
78 - (void)setFrequency:(iCalRecurrenceFrequency)_frequency;
79 - (iCalRecurrenceFrequency)frequency;
80
81 - (void)setRepeatInterval:(int)_repeatInterval;
82 - (int)repeatInterval;
83
84 - (void)setWeekStart:(iCalWeekDay)_weekStart;
85 - (iCalWeekDay)weekStart;
86
87 - (void)setByDayMask:(unsigned)_mask;
88 - (unsigned)byDayMask;
89   
90 /* count and untilDate are mutually exclusive */
91
92 - (void)setRepeatCount:(unsigned)_repeatCount;
93 - (unsigned)repeatCount;
94
95 - (void)setUntilDate:(NSCalendarDate *)_untilDate;
96 - (NSCalendarDate *)untilDate;
97
98 - (BOOL)isInfinite;
99
100 /* parse complete iCal RRULE */
101
102 - (void)setRrule:(NSString *)_rrule; // TODO: weird name? (better: RRule?)
103
104 - (NSString *)iCalRepresentation;
105
106 @end
107
108 #endif  /* __NGiCal_iCalRecurrenceRule_H_ */