/* Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. OGo 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 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 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "UIxMailPartViewer.h" /* UIxMailPartICalViewer Show plain/calendar mail parts. */ @class SOGoDateFormatter; @interface UIxMailPartICalViewer : UIxMailPartViewer { id appointment; id attendee; SOGoDateFormatter *dateFormatter; id item; } @end #include #include #include "common.h" @implementation UIxMailPartICalViewer - (void)dealloc { [self->attendee release]; [self->item release]; [self->appointment release]; [self->dateFormatter release]; [super dealloc]; } // TODO: flush caches /* accessors */ - (SOGoAppointment *)appointment { NSString *iCalString; if (self->appointment != nil) return self->appointment; iCalString = [self flatContentAsString]; self->appointment = [[SOGoAppointment alloc] initWithICalString:iCalString]; return self->appointment; } /* formatters */ - (SOGoDateFormatter *)dateFormatter { if (self->dateFormatter == nil) { self->dateFormatter = [[SOGoDateFormatter alloc] initWithLocale:[self locale]]; [self->dateFormatter setFullWeekdayNameAndDetails]; } return self->dateFormatter; } /* below is copied from UIxAppointmentView, can we avoid that? */ - (NSString *)tabSelection { NSString *selection; selection = [self queryParameterForKey:@"tab"]; if (selection == nil) selection = @"attributes"; return selection; } - (void)setAttendee:(id)_attendee { ASSIGN(self->attendee, _attendee); } - (id)attendee { return self->attendee; } - (void)setItem:(id)_item { ASSIGN(self->item, _item); } - (id)item { return self->item; } - (NSCalendarDate *)startTime { NSCalendarDate *date; date = [[self appointment] startDate]; [date setTimeZone:[self viewTimeZone]]; return date; } - (NSCalendarDate *)endTime { NSCalendarDate *date; date = [[self appointment] endDate]; [date setTimeZone:[self viewTimeZone]]; return date; } - (NSString *)resourcesAsString { NSArray *resources, *cns; resources = [[self appointment] resources]; cns = [resources valueForKey:@"cnForDisplay"]; return [cns componentsJoinedByString:@"
"]; } - (NSString *)categoriesAsString { unsigned i, count; NSArray *cats; NSMutableString *s; s = [[NSMutableString alloc] init]; cats = [((SOGoAppointment *)self->appointment) categories]; count = [cats count]; for(i = 0; i < count; i++) { NSString *cat, *label; cat = [cats objectAtIndex:i]; label = [self labelForKey:cat]; [s appendString:label]; if(i != (count - 1)) [s appendString:@", "]; } return s; } @end /* UIxMailPartICalViewer */