/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
- OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with OGo; see the file COPYING. If not, write to the
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#include "iCalEvent.h"
#include "iCalPerson.h"
#include "iCalEventChanges.h"
+#include "iCalRecurrenceRule.h"
#include "iCalRenderer.h"
#include <NGExtensions/NGCalendarDateRange.h>
#include "common.h"
@implementation iCalEvent
- (void)dealloc {
- [self->duration release];
- [self->endDate release];
- [self->recurrenceRule release];
+ [self->endDate release];
+ [self->duration release];
+ [self->transparency release];
[super dealloc];
}
return 0.0;
}
-- (void)setRecurrenceRule:(NSString *)_recurrenceRule {
- ASSIGNCOPY(self->recurrenceRule, _recurrenceRule);
-}
-- (NSString *)recurrenceRule {
- return self->recurrenceRule;
-}
-
- (void)setTransparency:(NSString *)_transparency {
ASSIGNCOPY(self->transparency, _transparency);
}
}
/* TODO: FIX THIS!
- NOTE: How do we find out if appointment is all day? Is this
- 0:00 - 23:59 GMT??? How do other's handle this?
+ The problem is, that startDate/endDate are inappropriately modelled here.
+ We'd need to have a special iCalDate in order to fix all the mess.
+ For the time being, we chose allday to mean 00:00 - 23:59 in startDate's
+ timezone.
*/
- (BOOL)isAllDay {
+ NSCalendarDate *ed;
+
if (![self hasEndDate])
return NO;
+
+ ed = [[[self endDate] copy] autorelease];
+ [ed setTimeZone:[self->startDate timeZone]];
+ if (([self->startDate hourOfDay] == 0) &&
+ ([self->startDate minuteOfHour] == 0) &&
+ ([ed hourOfDay] == 23) &&
+ ([ed minuteOfHour] == 59))
+ return YES;
return NO;
}
-- (BOOL)isRecurrent {
- if ([self recurrenceRule])
- return YES;
- return NO;
-}
-
-/* TODO: FIX THIS FOR RECURRENCY! */
- (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range {
if (![self isRecurrent]) {
if (self->startDate && self->endDate) {
return [_range containsDate:self->startDate];
}
}
+ else {
+ NGCalendarDateRange *fir;
+
+ fir = [NGCalendarDateRange calendarDateRangeWithStartDate:self->startDate
+ endDate:self->endDate];
+
+ return [self isWithinCalendarDateRange:_range
+ firstInstanceCalendarDateRange:fir];
+ }
return NO;
}
+- (NSArray *)recurrenceRangesWithinCalendarDateRange:(NGCalendarDateRange *)_r {
+ NGCalendarDateRange *fir;
+
+ if (![self isRecurrent])
+ return nil;
+
+ fir = [NGCalendarDateRange calendarDateRangeWithStartDate:self->startDate
+ endDate:self->endDate];
+ return [self recurrenceRangesWithinCalendarDateRange:_r
+ firstInstanceCalendarDateRange:fir];
+}
+
+- (NSCalendarDate *)lastPossibleRecurrenceStartDate {
+ NGCalendarDateRange *fir;
+
+ if (![self isRecurrent])
+ return nil;
+
+ fir = [NGCalendarDateRange calendarDateRangeWithStartDate:self->startDate
+ endDate:self->endDate];
+ return [self lastPossibleRecurrenceStartDateUsingFirstInstanceCalendarDateRange:fir];
+}
+
/* ical typing */
- (NSString *)entityName {
if ([self hasAlarms])
[ms appendFormat:@" alarms=%@", self->alarms];
- if (self->recurrenceRule)
- [ms appendFormat:@" recurrenceRule=%@", self->recurrenceRule];
-
[ms appendString:@">"];
return ms;
}