]> err.no Git - sope/blob - sope-ical/NGiCal/iCalRecurrenceRule.h
a36d67536ba58815e145b0595837709efc8267a6
[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 // TODO: we could use string constants?
38 typedef enum {
39   iCalRecurrenceFrequenceSecondly = 1,
40   iCalRecurrenceFrequenceMinutely = 2,
41   iCalRecurrenceFrequenceHourly   = 3,
42   iCalRecurrenceFrequenceDaily    = 4,
43   iCalRecurrenceFrequenceWeekly   = 5,
44   iCalRecurrenceFrequenceMonthly  = 6,
45   iCalRecurrenceFrequenceYearly   = 7,
46 } iCalRecurrenceFrequency;
47
48 typedef enum {
49   iCalWeekDayMonday    = 1,
50   iCalWeekDayTuesday   = 2,
51   iCalWeekDayWednesday = 4,
52   iCalWeekDayThursday  = 8,
53   iCalWeekDayFriday    = 16,
54   iCalWeekDaySaturday  = 32,
55   iCalWeekDaySunday    = 64,
56 } iCalWeekDay;
57
58 @class NSString, NSCalendarDate, NGCalendarDateRange;
59
60 @interface iCalRecurrenceRule : NSObject
61 {
62   iCalRecurrenceFrequency frequency;
63   int            interval;
64   unsigned       repeatCount;
65   NSCalendarDate *untilDate;
66   struct {
67     unsigned weekStart: 7;
68     unsigned mask:      7;
69     unsigned useOccurence:1;
70     unsigned reserved:1;
71   } byDay;
72   int byDayOccurence1;
73
74   NSString       *rrule;
75 }
76
77 + (id)recurrenceRuleWithICalRepresentation:(NSString *)_iCalRep;
78 - (id)initWithString:(NSString *)_str;
79
80 /* accessors */
81
82 - (void)setFrequency:(iCalRecurrenceFrequency)_frequency;
83 - (iCalRecurrenceFrequency)frequency;
84
85 - (void)setRepeatInterval:(int)_repeatInterval;
86 - (int)repeatInterval;
87
88 - (void)setWeekStart:(iCalWeekDay)_weekStart;
89 - (iCalWeekDay)weekStart;
90
91 - (void)setByDayMask:(unsigned)_mask;
92 - (unsigned)byDayMask;
93 - (int)byDayOccurence1;
94   
95 /* count and untilDate are mutually exclusive */
96
97 - (void)setRepeatCount:(unsigned)_repeatCount;
98 - (unsigned)repeatCount;
99
100 - (void)setUntilDate:(NSCalendarDate *)_untilDate;
101 - (NSCalendarDate *)untilDate;
102
103 - (BOOL)isInfinite;
104
105 /* parse complete iCal RRULE */
106
107 - (void)setRrule:(NSString *)_rrule; // TODO: weird name? (better: RRule?)
108
109 - (NSString *)iCalRepresentation;
110
111 @end
112
113 #endif  /* __NGiCal_iCalRecurrenceRule_H_ */