From 263f0b99a35e66907010fc13bbdf910935a289f0 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 21 Feb 2005 02:10:35 +0000 Subject: [PATCH] started an iCal event viewer git-svn-id: http://svn.opengroupware.org/SOGo/trunk@598 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/MailPartViewers/ChangeLog | 4 + SOGo/UI/MailPartViewers/GNUmakefile | 2 + .../MailPartViewers/UIxMailPartHTMLViewer.m | 30 ++++ .../MailPartViewers/UIxMailPartICalViewer.m | 152 ++++++++++++++++++ .../MailPartViewers/UIxMailPartLinkViewer.h | 53 ++++++ .../MailPartViewers/UIxMailPartLinkViewer.m | 29 +--- .../MailPartViewers/UIxMailPartMixedViewer.m | 2 +- .../MailPartViewers/UIxMailRenderingContext.h | 2 + .../MailPartViewers/UIxMailRenderingContext.m | 26 ++- SOGo/UI/MailPartViewers/Version | 2 +- SOGo/UI/Mailer/mailer.css | 8 +- SOGo/UI/Scheduler/UIxAppointmentView.m | 2 +- SOGo/UI/Templates/UIxMailPartHTMLViewer.wox | 23 +++ SOGo/UI/Templates/UIxMailPartICalViewer.wox | 70 ++++++++ 14 files changed, 372 insertions(+), 33 deletions(-) create mode 100644 SOGo/UI/MailPartViewers/UIxMailPartHTMLViewer.m create mode 100644 SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m create mode 100644 SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.h create mode 100644 SOGo/UI/Templates/UIxMailPartHTMLViewer.wox create mode 100644 SOGo/UI/Templates/UIxMailPartICalViewer.wox diff --git a/SOGo/UI/MailPartViewers/ChangeLog b/SOGo/UI/MailPartViewers/ChangeLog index 3ed4168a..e6f3dc7b 100644 --- a/SOGo/UI/MailPartViewers/ChangeLog +++ b/SOGo/UI/MailPartViewers/ChangeLog @@ -1,3 +1,7 @@ +2005-02-21 Helge Hess + + * prepared HTML and iCal mail part viewers (0.9.3) + 2005-02-20 Helge Hess * moved in UIxMailSizeFormatter (v0.9.2) diff --git a/SOGo/UI/MailPartViewers/GNUmakefile b/SOGo/UI/MailPartViewers/GNUmakefile index 9d1b8b97..5582b818 100644 --- a/SOGo/UI/MailPartViewers/GNUmakefile +++ b/SOGo/UI/MailPartViewers/GNUmakefile @@ -21,6 +21,8 @@ MailPartViewers_OBJC_FILES += \ UIxMailPartMixedViewer.m \ UIxMailPartAlternativeViewer.m \ UIxMailPartMessageViewer.m \ + UIxMailPartICalViewer.m \ + UIxMailPartHTMLViewer.m \ MailPartViewers_RESOURCE_FILES += \ Version \ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartHTMLViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartHTMLViewer.m new file mode 100644 index 00000000..ab7746de --- /dev/null +++ b/SOGo/UI/MailPartViewers/UIxMailPartHTMLViewer.m @@ -0,0 +1,30 @@ +/* + 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 "UIxMailPartLinkViewer.h" + +@interface UIxMailPartHTMLViewer : UIxMailPartLinkViewer +@end + +#include "common.h" + +@implementation UIxMailPartHTMLViewer +@end /* UIxMailPartHTMLViewer */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m new file mode 100644 index 00000000..089efca5 --- /dev/null +++ b/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m @@ -0,0 +1,152 @@ +/* + 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 */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.h b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.h new file mode 100644 index 00000000..a7422186 --- /dev/null +++ b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.h @@ -0,0 +1,53 @@ +/* + 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. +*/ + +#ifndef __Mailer_UIxMailPartLinkViewer_H__ +#define __Mailer_UIxMailPartLinkViewer_H__ + +#include "UIxMailPartViewer.h" + +/* + UIxMailPartLinkViewer + + The generic viewer for all kinds of attachments. Renders a link to download + the attachment. + + TODO: show info based on the 'bodyInfo' dictionary: + { + bodyId = ""; + description = ""; + encoding = BASE64; + parameterList = { + "x-unix-mode" = 0666; + name = "IncoWEBOpenGroupwarepresentation.pdf"; + }; + size = 1314916; + subtype = PDF; type = application; + } +*/ + +@interface UIxMailPartLinkViewer : UIxMailPartViewer +{ +} + +@end + +#endif /* __Mailer_UIxMailPartLinkViewer_H__ */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m index 41d95c32..76968bac 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m +++ b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m @@ -19,34 +19,7 @@ 02111-1307, USA. */ -#include "UIxMailPartViewer.h" - -/* - UIxMailPartLinkViewer - - The generic viewer for all kinds of attachments. Renders a link to download - the attachment. - - TODO: show info based on the 'bodyInfo' dictionary: - { - bodyId = ""; - description = ""; - encoding = BASE64; - parameterList = { - "x-unix-mode" = 0666; - name = "IncoWEBOpenGroupwarepresentation.pdf"; - }; - size = 1314916; - subtype = PDF; type = application; - } -*/ - -@interface UIxMailPartLinkViewer : UIxMailPartViewer -{ -} - -@end - +#include "UIxMailPartLinkViewer.h" #include "common.h" @implementation UIxMailPartLinkViewer diff --git a/SOGo/UI/MailPartViewers/UIxMailPartMixedViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartMixedViewer.m index 27404c09..26d4fbba 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartMixedViewer.m +++ b/SOGo/UI/MailPartViewers/UIxMailPartMixedViewer.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. diff --git a/SOGo/UI/MailPartViewers/UIxMailRenderingContext.h b/SOGo/UI/MailPartViewers/UIxMailRenderingContext.h index 6e6ef48b..fa1fbffc 100644 --- a/SOGo/UI/MailPartViewers/UIxMailRenderingContext.h +++ b/SOGo/UI/MailPartViewers/UIxMailRenderingContext.h @@ -45,6 +45,8 @@ WOComponent *imageViewer; WOComponent *linkViewer; WOComponent *messageViewer; + WOComponent *iCalViewer; + WOComponent *htmlViewer; } - (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx; diff --git a/SOGo/UI/MailPartViewers/UIxMailRenderingContext.m b/SOGo/UI/MailPartViewers/UIxMailRenderingContext.m index b8ceb214..2ee998f5 100644 --- a/SOGo/UI/MailPartViewers/UIxMailRenderingContext.m +++ b/SOGo/UI/MailPartViewers/UIxMailRenderingContext.m @@ -38,6 +38,8 @@ - (void)dealloc { [self->alternativeViewer release]; + [self->iCalViewer release]; + [self->htmlViewer release]; [self->mixedViewer release]; [self->textViewer release]; [self->imageViewer release]; @@ -53,9 +55,11 @@ [self->alternativeViewer release]; self->alternativeViewer = nil; [self->mixedViewer release]; self->mixedViewer = nil; [self->textViewer release]; self->textViewer = nil; + [self->htmlViewer release]; self->htmlViewer = nil; [self->imageViewer release]; self->imageViewer = nil; [self->linkViewer release]; self->linkViewer = nil; [self->messageViewer release]; self->messageViewer = nil; + [self->iCalViewer release]; self->iCalViewer = nil; } /* fetching */ @@ -119,6 +123,14 @@ return self->linkViewer; } +- (WOComponent *)htmlViewer { + if (self->htmlViewer == nil) { + self->htmlViewer = + [[self->viewer pageWithName:@"UIxMailPartHTMLViewer"] retain]; + } + return self->htmlViewer; +} + - (WOComponent *)messageViewer { if (self->messageViewer == nil) { self->messageViewer = @@ -127,6 +139,14 @@ return self->messageViewer; } +- (WOComponent *)iCalViewer { + if (self->iCalViewer == nil) { + self->iCalViewer = + [[self->viewer pageWithName:@"UIxMailPartICalViewer"] retain]; + } + return self->iCalViewer; +} + - (WOComponent *)viewerForBodyInfo:(id)_info { NSString *mt, *st; @@ -144,8 +164,12 @@ else if ([mt isEqualToString:@"text"]) { if ([st isEqualToString:@"plain"]) return [self textViewer]; + if ([st isEqualToString:@"html"]) - return [self textViewer]; // TODO: temporary workaround + return [self htmlViewer]; // TODO: temporary workaround + + if ([st isEqualToString:@"calendar"]) + return [self iCalViewer]; } else if ([mt isEqualToString:@"image"]) return [self imageViewer]; diff --git a/SOGo/UI/MailPartViewers/Version b/SOGo/UI/MailPartViewers/Version index ae165207..097483e1 100644 --- a/SOGo/UI/MailPartViewers/Version +++ b/SOGo/UI/MailPartViewers/Version @@ -1,5 +1,5 @@ # version file -SUBMINOR_VERSION:=2 +SUBMINOR_VERSION:=3 # v0.9.1 requires libNGMime v4.5.213 diff --git a/SOGo/UI/Mailer/mailer.css b/SOGo/UI/Mailer/mailer.css index ccc2e063..ff116df0 100644 --- a/SOGo/UI/Mailer/mailer.css +++ b/SOGo/UI/Mailer/mailer.css @@ -478,7 +478,7 @@ div.linked_attachment_frame { } div.linked_attachment_body { - font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif; + font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif; font-size: 10pt; padding: 4px; @@ -496,3 +496,9 @@ div.linked_attachment_meta { border-width: 0; padding: 2px; } +table.linked_attachment_meta { + font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif; + font-size: 10pt; + color: #444444; + font-style: italic; +} diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.m b/SOGo/UI/Scheduler/UIxAppointmentView.m index 4811c9d5..8ecdabb5 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.m +++ b/SOGo/UI/Scheduler/UIxAppointmentView.m @@ -120,7 +120,7 @@ - (SOGoAppointment *)appointment { NSString *iCalString; - if (self->appointment) + if (self->appointment != nil) return self->appointment; iCalString = [[self clientObject] valueForKey:@"iCalString"]; diff --git a/SOGo/UI/Templates/UIxMailPartHTMLViewer.wox b/SOGo/UI/Templates/UIxMailPartHTMLViewer.wox new file mode 100644 index 00000000..8ca1d5f7 --- /dev/null +++ b/SOGo/UI/Templates/UIxMailPartHTMLViewer.wox @@ -0,0 +1,23 @@ + +
+ + + +
+ +
+ : + / + , + + : + +
+
+
diff --git a/SOGo/UI/Templates/UIxMailPartICalViewer.wox b/SOGo/UI/Templates/UIxMailPartICalViewer.wox new file mode 100644 index 00000000..3fff614c --- /dev/null +++ b/SOGo/UI/Templates/UIxMailPartICalViewer.wox @@ -0,0 +1,70 @@ + +
+ + +
+ : +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
: + + + - + +
:
: + + (), +
: + + + (), + + +
: + +
+
+
+ + +
+
-- 2.39.5