@implementation iCalRepeatableEntityObject (OCS)
-- (NSString *)cycleInfo {
- NSMutableDictionary *cycleInfo;
- NSMutableArray *ma;
- NSArray *a;
- unsigned count;
+- (NSArray *) _indexedRules: (NSArray *) rules
+{
+ NSMutableArray *ma;
+ unsigned int i, count;
+ NSString *valuesString;
- if (![self isRecurrent])
- return nil;
+ ma = nil;
+ count = [rules count];
+ if (count > 0)
+ {
+ ma = [NSMutableArray arrayWithCapacity:count];
+ for (i = 0; i < count; i++)
+ {
+ iCalRecurrenceRule *rule;
+
+ rule = [rules objectAtIndex:i];
+#warning we could return an NSArray instead and feed it as such to the iCalRecurrenceRule in SOGoAppointmentFolder...
+ valuesString = [[rule values] componentsJoinedByString: @";"];
+ [ma addObject: valuesString];
+ }
+ }
- cycleInfo = [NSMutableDictionary dictionaryWithCapacity:3];
+ return ma;
+}
- /* rules */
- a = [self recurrenceRules];
- count = [a count];
- if (count > 0) {
- unsigned i;
+- (NSString *) cycleInfo
+{
+ NSArray *rules;
+ NSString *value;
+ NSMutableDictionary *cycleInfo;
- ma = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i++) {
- iCalRecurrenceRule *rule;
-
- rule = [a objectAtIndex:i];
- [ma addObject: [rule versitString]];
- }
- [cycleInfo setObject:ma forKey:@"rules"];
- }
+ if ([self isRecurrent])
+ {
+ cycleInfo = [NSMutableDictionary dictionaryWithCapacity: 3];
- /* exception rules */
- a = [self exceptionRules];
- count = [a count];
- if (count > 0) {
- unsigned i;
-
- ma = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i++) {
- iCalRecurrenceRule *rule;
+ /* rules */
+ rules = [self _indexedRules: [self recurrenceRules]];
+ if (rules)
+ [cycleInfo setObject: rules forKey: @"rules"];
- rule = [a objectAtIndex:i];
- [ma addObject: [rule versitString]];
- }
- [cycleInfo setObject:ma forKey:@"exRules"];
- }
-
- /* exception dates */
- a = [self exceptionDates];
- count = [a count];
- if (count > 0) {
- unsigned i;
-
- ma = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i++) {
- NSCalendarDate *date;
+ rules = [self _indexedRules: [self exceptionRules]];
+ if (rules)
+ [cycleInfo setObject: rules forKey: @"exRules"];
- date = [a objectAtIndex:i];
- [ma addObject:[date icalString]];
+ rules = [self _indexedRules: [self exceptionDates]];
+ if (rules)
+ [cycleInfo setObject: rules forKey: @"exDates"];
+
+ value = [cycleInfo description];
}
- [cycleInfo setObject:ma forKey:@"exDates"];
- }
+ else
+ value = nil;
- return [cycleInfo description];
+ return value;
}
@end
+2007-07-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+
+ * iCalRecurrenceRule.m ([iCalRecurrenceRule
+ +recurrenceRuleWithICalRepresentation:_iCalRep]): the
+ representation is generally a series of values separated by a ";".
+ Therefore we need to split those values and feed them one by one.
+ ([iCalRecurrenceRule -weekDayFromICalRepresentation:_day]): return
+ -1 instead of raising an exception if the week day could not be
+ recognized.
+
+ * CardElement.m ([CardElement -versitString]): remove the ending
+ "\r\n".
+
2007-06-12 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* iCalDateTime.m ([iCalDateTime
+ (id) recurrenceRuleWithICalRepresentation: (NSString *) _iCalRep
{
- return [self simpleElementWithTag: @"rrule" value: _iCalRep];
+ iCalRecurrenceRule *rule;
+
+ rule = [self elementWithTag: @"rrule"];
+ if ([_iCalRep length] > 0)
+ [rule addValues: [_iCalRep componentsSeparatedByString: @";"]];
+
+ return rule;
}
- (id) init
return mask;
}
-#warning this is fucked up
+#warning this is bad
- (int) byDayOccurence1
{
return 0;
if (c1 == 'u' || c1 == 'U') return iCalWeekDaySunday;
}
}
-
- // TODO: do not raise but rather return an error value?
- [NSException raise:NSGenericException
- format:@"Incorrect weekDay '%@' specified!", _day];
- return iCalWeekDayMonday; /* keep compiler happy */
+
+ return -1;
+// // TODO: do not raise but rather return an error value?
+// [NSException raise:NSGenericException
+// format:@"Incorrect weekDay '%@' specified!", _day];
+// return iCalWeekDayMonday; /* keep compiler happy */
}
- (NSString *) iCalRepresentationForWeekDay: (iCalWeekDay) _weekDay