/*
- 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.
*/
-// $Id$
#include "iCalEvent.h"
#include "iCalPerson.h"
+#include "iCalEventChanges.h"
+#include "iCalRecurrenceRule.h"
+#include "iCalRenderer.h"
+#include <NGExtensions/NGCalendarDateRange.h>
#include "common.h"
@interface NSString(DurationTimeInterval)
@implementation iCalEvent
- (void)dealloc {
- [self->duration release];
- [self->endDate release];
+ [self->endDate release];
+ [self->duration release];
+ [self->transparency release];
[super dealloc];
}
return self->endDate ? YES : NO;
}
-- (void)setTransp:(NSString *)_transp {
- /* ignore transp ... (used by Evo 'TRANSP:OPAQUE') */
-}
-
- (void)setDuration:(NSString *)_value {
ASSIGNCOPY(self->duration, _value);
}
return 0.0;
}
+- (void)setTransparency:(NSString *)_transparency {
+ ASSIGNCOPY(self->transparency, _transparency);
+}
+- (NSString *)transparency {
+ return self->transparency;
+}
+
+/* convenience */
+
+- (BOOL)isOpaque {
+ NSString *s;
+
+ s = [self transparency];
+ if (s && [[s uppercaseString] isEqualToString:@"TRANSPARENT"])
+ return NO;
+ return YES; /* default is OPAQUE, see RFC2445, Section 4.8.2.7 */
+}
+
+/* TODO: FIX 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)isWithinCalendarDateRange:(NGCalendarDateRange *)_range {
+ if (![self isRecurrent]) {
+ if (self->startDate && self->endDate) {
+ NGCalendarDateRange *r;
+
+ r = [NGCalendarDateRange calendarDateRangeWithStartDate:self->startDate
+ endDate:self->endDate];
+ return [_range containsDateRange:r];
+ }
+ else {
+ 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 {
return ms;
}
+/* changes */
+
+- (iCalEventChanges *)getChangesRelativeToEvent:(iCalEvent *)_event {
+ return [iCalEventChanges changesFromEvent:_event
+ toEvent:self];
+}
+
+/* generating iCal content */
+
+- (NSString *)vEventString {
+ return [[iCalRenderer sharedICalendarRenderer] vEventStringForEvent:self];
+}
+
@end /* iCalEvent */
@implementation NSString(DurationTimeInterval)