]> err.no Git - scalable-opengroupware.org/blob - OGoContentStore/iCalRepeatableEntityObject+OCS.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1031 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / OGoContentStore / iCalRepeatableEntityObject+OCS.m
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo 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   OGo 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 OGo; 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 // $Id$
22
23 #include "iCalRepeatableEntityObject+OCS.h"
24 #include "common.h"
25
26 @implementation iCalRepeatableEntityObject (OCS)
27
28 - (NSString *)cycleInfo {
29   NSMutableDictionary *cycleInfo;
30   NSMutableArray      *ma;
31   NSArray             *a;
32   unsigned            count;
33
34   if (![self isRecurrent])
35     return nil;
36
37   cycleInfo = [NSMutableDictionary dictionaryWithCapacity:3];
38
39   /* rules */
40   a     = [self recurrenceRules];
41   count = [a count];
42   if (count > 0) {
43     unsigned i;
44
45     ma = [NSMutableArray arrayWithCapacity:count];
46     for (i = 0; i < count; i++) {
47       iCalRecurrenceRule *rule;
48       
49       rule = [a objectAtIndex:i];
50       [ma addObject: [rule versitString]];
51     }
52     [cycleInfo setObject:ma forKey:@"rules"];
53   }
54
55   /* exception rules */
56   a     = [self exceptionRules];
57   count = [a count];
58   if (count > 0) {
59     unsigned i;
60     
61     ma = [NSMutableArray arrayWithCapacity:count];
62     for (i = 0; i < count; i++) {
63       iCalRecurrenceRule *rule;
64       
65       rule = [a objectAtIndex:i];
66       [ma addObject: [rule versitString]];
67     }
68     [cycleInfo setObject:ma forKey:@"exRules"];
69   }
70   
71   /* exception dates */
72   a     = [self exceptionDates];
73   count = [a count];
74   if (count > 0) {
75     unsigned i;
76     
77     ma = [NSMutableArray arrayWithCapacity:count];
78     for (i = 0; i < count; i++) {
79       NSCalendarDate *date;
80       
81       date = [a objectAtIndex:i];
82       [ma addObject:[date icalString]];
83     }
84     [cycleInfo setObject:ma forKey:@"exDates"];
85   }
86
87   return [cycleInfo description];
88 }
89 @end