]> err.no Git - scalable-opengroupware.org/blob - OGoContentStore/iCalRepeatableEntityObject+OCS.m
5491d12f9c1d8c3be0d2bb3165ce007d2fc092de
[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 - (NSArray *) _indexedRules: (NSArray *) rules
29 {
30   NSMutableArray *ma;
31   unsigned int i, count;
32   NSString *valuesString;
33
34   ma = nil;
35   count = [rules count];
36   if (count > 0)
37     {
38       ma = [NSMutableArray arrayWithCapacity:count];
39       for (i = 0; i < count; i++)
40         {
41           iCalRecurrenceRule *rule;
42           
43           rule = [rules objectAtIndex:i];
44 #warning we could return an NSArray instead and feed it as such to the iCalRecurrenceRule in SOGoAppointmentFolder...
45           valuesString = [[rule values] componentsJoinedByString: @";"];
46           [ma addObject: valuesString];
47         }
48     }
49
50   return ma;
51 }
52
53 - (NSString *) cycleInfo
54 {
55   NSArray *rules;
56   NSString *value;
57   NSMutableDictionary *cycleInfo;
58
59   if ([self isRecurrent])
60     {
61       cycleInfo = [NSMutableDictionary dictionaryWithCapacity: 3];
62
63       /* rules */
64       rules = [self _indexedRules: [self recurrenceRules]];
65       if (rules)
66         [cycleInfo setObject: rules forKey: @"rules"];
67       
68       rules = [self _indexedRules: [self exceptionRules]];
69       if (rules)
70         [cycleInfo setObject: rules forKey: @"exRules"];
71       
72       rules = [self _indexedRules: [self exceptionDates]];
73       if (rules)
74         [cycleInfo setObject: rules forKey: @"exDates"];
75
76       value = [cycleInfo description];
77     }
78   else
79     value = nil;
80
81   return value;
82 }
83 @end