From 54f9dc3cce1712b7faeefd1dd988f2a3d93f8172 Mon Sep 17 00:00:00 2001 From: helge Date: Sat, 30 Jul 2005 17:02:58 +0000 Subject: [PATCH] improved reliability on iCal viewer some work on Kolab viewers git-svn-id: http://svn.opengroupware.org/SOGo/trunk@924 d1b88da0-ebda-0310-925b-ed51d893ca5b --- UI/MailPartViewers/ChangeLog | 18 +++- UI/MailPartViewers/GNUmakefile | 5 + .../UIxKolabPartContactViewer.m | 36 +++++++ UI/MailPartViewers/UIxKolabPartEventViewer.m | 36 +++++++ UI/MailPartViewers/UIxKolabPartTaskViewer.m | 36 +++++++ UI/MailPartViewers/UIxKolabPartViewer.h | 39 +++++++ UI/MailPartViewers/UIxKolabPartViewer.m | 48 +++++++++ UI/MailPartViewers/UIxMailPartICalViewer.m | 23 +++- UI/MailPartViewers/UIxMailPartViewer.h | 7 ++ UI/MailPartViewers/UIxMailPartViewer.m | 19 ++++ UI/MailPartViewers/UIxMailRenderingContext.m | 13 +-- UI/MailPartViewers/Version | 2 +- UI/Templates/ChangeLog | 25 +++-- UI/Templates/MailPartViewers/GNUmakefile | 12 +++ .../UIxKolabPartContactViewer.wox | 100 ++++++++++++++++++ .../UIxKolabPartEventViewer.wox | 16 +++ .../UIxKolabPartTaskViewer.wox | 16 +++ .../MailPartViewers/UIxMailPartICalViewer.wox | 12 +++ UI/Templates/MailerUI/UIxMailView.wox | 9 ++ 19 files changed, 450 insertions(+), 22 deletions(-) create mode 100644 UI/MailPartViewers/UIxKolabPartContactViewer.m create mode 100644 UI/MailPartViewers/UIxKolabPartEventViewer.m create mode 100644 UI/MailPartViewers/UIxKolabPartTaskViewer.m create mode 100644 UI/MailPartViewers/UIxKolabPartViewer.h create mode 100644 UI/MailPartViewers/UIxKolabPartViewer.m create mode 100644 UI/Templates/MailPartViewers/GNUmakefile create mode 100644 UI/Templates/MailPartViewers/UIxKolabPartContactViewer.wox create mode 100644 UI/Templates/MailPartViewers/UIxKolabPartEventViewer.wox create mode 100644 UI/Templates/MailPartViewers/UIxKolabPartTaskViewer.wox diff --git a/UI/MailPartViewers/ChangeLog b/UI/MailPartViewers/ChangeLog index ae458aad..42c280a1 100644 --- a/UI/MailPartViewers/ChangeLog +++ b/UI/MailPartViewers/ChangeLog @@ -1,13 +1,25 @@ 2005-07-30 Helge Hess + + * v0.9.20 + + * UIxMailPartViewer.m: added ability to use a fallback string encoding + in case the default one or the one specified in the content-type did + fail (this can happen with Outlook iCal mails ...). + * UIxMailPartICalViewer.m: hardened against missing content data, use + Latin-1 as a fallback encoding in case the part encoding didn't work + out. + + * prepared MIME part viewers for Kolab XML types + * UIxMailRenderingContext.m: prepared some support for Kolab types in IMAP4 (v0.9.19) - + 2005-07-27 Helge Hess - + * English.lproj/Localizable.strings: added a missing semicolon (v0.9.18) - + 2005-07-23 Helge Hess * UIxMailPartICalViewer.m: fixed include path for new hierarchy diff --git a/UI/MailPartViewers/GNUmakefile b/UI/MailPartViewers/GNUmakefile index 23a59d65..44e1aeed 100644 --- a/UI/MailPartViewers/GNUmakefile +++ b/UI/MailPartViewers/GNUmakefile @@ -27,6 +27,11 @@ MailPartViewers_OBJC_FILES += \ UIxMailPartHTMLViewer.m \ \ UIxMailPartICalAction.m \ + \ + UIxKolabPartViewer.m \ + UIxKolabPartContactViewer.m \ + UIxKolabPartEventViewer.m \ + UIxKolabPartTaskViewer.m \ MailPartViewers_RESOURCE_FILES += \ Version \ diff --git a/UI/MailPartViewers/UIxKolabPartContactViewer.m b/UI/MailPartViewers/UIxKolabPartContactViewer.m new file mode 100644 index 00000000..9c9a948a --- /dev/null +++ b/UI/MailPartViewers/UIxKolabPartContactViewer.m @@ -0,0 +1,36 @@ +/* + Copyright (C) 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 "UIxKolabPartViewer.h" + +/* + UIxKolabPartContactViewer + + Show application/x-vnd.kolab.contact types. (Kolab XML content) +*/ + +@interface UIxKolabPartContactViewer : UIxKolabPartViewer +@end + +#include "common.h" + +@implementation UIxKolabPartContactViewer +@end /* UIxKolabPartContactViewer */ diff --git a/UI/MailPartViewers/UIxKolabPartEventViewer.m b/UI/MailPartViewers/UIxKolabPartEventViewer.m new file mode 100644 index 00000000..9745be08 --- /dev/null +++ b/UI/MailPartViewers/UIxKolabPartEventViewer.m @@ -0,0 +1,36 @@ +/* + Copyright (C) 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 "UIxKolabPartViewer.h" + +/* + UIxKolabPartEventViewer + + Show application/x-vnd.kolab.event types. (Kolab XML content) +*/ + +@interface UIxKolabPartEventViewer : UIxKolabPartViewer +@end + +#include "common.h" + +@implementation UIxKolabPartEventViewer +@end /* UIxKolabPartEventViewer */ diff --git a/UI/MailPartViewers/UIxKolabPartTaskViewer.m b/UI/MailPartViewers/UIxKolabPartTaskViewer.m new file mode 100644 index 00000000..87a361c1 --- /dev/null +++ b/UI/MailPartViewers/UIxKolabPartTaskViewer.m @@ -0,0 +1,36 @@ +/* + Copyright (C) 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 "UIxKolabPartViewer.h" + +/* + UIxKolabPartTaskViewer + + Show application/x-vnd.kolab.task types. (Kolab XML content) +*/ + +@interface UIxKolabPartTaskViewer : UIxKolabPartViewer +@end + +#include "common.h" + +@implementation UIxKolabPartTaskViewer +@end /* UIxKolabPartTaskViewer */ diff --git a/UI/MailPartViewers/UIxKolabPartViewer.h b/UI/MailPartViewers/UIxKolabPartViewer.h new file mode 100644 index 00000000..af288097 --- /dev/null +++ b/UI/MailPartViewers/UIxKolabPartViewer.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 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_UIxKolabPartViewer_H__ +#define __Mailer_UIxKolabPartViewer_H__ + +#include "UIxMailPartViewer.h" + +/* + UIxKolabPartContactViewer + + Superclass for viewers which show the application/x-vnd.* XML documents. +*/ + +@interface UIxKolabPartViewer : UIxMailPartViewer +{ +} + +@end + +#endif /* __Mailer_UIxKolabPartViewer_H__ */ diff --git a/UI/MailPartViewers/UIxKolabPartViewer.m b/UI/MailPartViewers/UIxKolabPartViewer.m new file mode 100644 index 00000000..0d754469 --- /dev/null +++ b/UI/MailPartViewers/UIxKolabPartViewer.m @@ -0,0 +1,48 @@ +/* + Copyright (C) 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 "UIxKolabPartViewer.h" +#include "common.h" +#include + +@implementation UIxKolabPartViewer + +static id domBuilder = nil; + ++ (void)initialize { + DOMBuilderFactory *factory + = [DOMBuilderFactory standardDOMBuilderFactory]; + + domBuilder = [[factory createDOMBuilderForMimeType:@"text/xml"] retain]; + NSLog(@"Note(%@): using DOM builder: %@", + NSStringFromClass(self), domBuilder); +} + +- (id)domDocument { + /* + Note: this ignores the charset MIME header and will rely on proper + encoding header in the XML. + */ + return [domBuilder buildFromSource:[self decodedFlatContent] + systemId:@"Kolab Mail Object"]; +} + +@end /* UIxKolabPartViewer */ diff --git a/UI/MailPartViewers/UIxMailPartICalViewer.m b/UI/MailPartViewers/UIxMailPartICalViewer.m index 80da457d..9b42256b 100644 --- a/UI/MailPartViewers/UIxMailPartICalViewer.m +++ b/UI/MailPartViewers/UIxMailPartICalViewer.m @@ -82,6 +82,23 @@ [self->item release]; self->item = nil; } +/* raw content handling */ + +- (NSStringEncoding)fallbackStringEncoding { + /* + iCalendar invitations sent by Outlook 2002 have the annoying bug that the + mail states an UTF-8 content encoding but the actual iCalendar content is + encoding in Latin-1 (or Windows Western?). + + As a result the content decoding will fail (TODO: always?). In this case we + try to decode with Latin-1. + + Note: we could check for the Outlook x-mailer, but it was considered better + to try Latin-1 as a fallback in any case (be tolerant). + */ + return NSISOLatin1StringEncoding; +} + /* accessors */ - (iCalCalendar *)inCalendar { @@ -90,7 +107,11 @@ if (self->inCalendar != nil) return [self->inCalendar isNotNull] ? self->inCalendar : nil; - iCalString = [self flatContentAsString]; + if ((iCalString = [self flatContentAsString]) == nil) { + [self errorWithFormat:@"Could not retrieve content string for part!"]; + self->inCalendar = [[NSNull null] retain]; + return nil; + } self->inCalendar = [[iCalCalendar parseCalendarFromSource:iCalString] retain]; diff --git a/UI/MailPartViewers/UIxMailPartViewer.h b/UI/MailPartViewers/UIxMailPartViewer.h index b539dae2..5cd25944 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.h +++ b/UI/MailPartViewers/UIxMailPartViewer.h @@ -32,6 +32,13 @@ Since part-viewers can be reused for multiple parts, you need to be careful in subclass to properly reset your specific state by overriding - resetPathCaches + + The part viewers have access to the rendering state using the + + [[self context] mailRenderingContext] + + object. This class provides several convenience methods to access mailpart + content. */ @class NSData, NSArray, NSFormatter; diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index 71442f6a..72ca9452 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -106,6 +106,9 @@ return [self flatContent]; } +- (NSStringEncoding)fallbackStringEncoding { + return 0; +} - (NSString *)flatContentAsString { /* Note: we even have the line count in the body-info! */ NSString *charset; @@ -132,9 +135,25 @@ s = [[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding]; s = [s autorelease]; } + if (s == nil) { + /* + Note: this can happend with iCalendar invitations sent by Outlook 2002. + It will mark the content as UTF-8 but actually deliver it as + Latin-1 (or Windows encoding?). + */ [self errorWithFormat:@"could not convert content to text, charset: '%@'", charset]; + if ([self fallbackStringEncoding] > 0) { + s = [[NSString alloc] initWithData:content + encoding:[self fallbackStringEncoding]]; + s = [s autorelease]; + + if (s == nil) { + [self errorWithFormat: + @" an attempt to use fallback encoding failed to."]; + } + } } return s; } diff --git a/UI/MailPartViewers/UIxMailRenderingContext.m b/UI/MailPartViewers/UIxMailRenderingContext.m index e3f3f411..a743983f 100644 --- a/UI/MailPartViewers/UIxMailRenderingContext.m +++ b/UI/MailPartViewers/UIxMailRenderingContext.m @@ -148,22 +148,23 @@ static BOOL showNamedTextAttachmentsInline = NO; /* Kolab viewers */ - (WOComponent *)kolabContactViewer { - return [self linkViewer]; + return [self->viewer pageWithName:@"UIxKolabPartContactViewer"]; } - (WOComponent *)kolabEventViewer { - return [self linkViewer]; + return [self->viewer pageWithName:@"UIxKolabPartEventViewer"]; } - (WOComponent *)kolabTodoViewer { - return [self linkViewer]; + return [self->viewer pageWithName:@"UIxKolabPartTodoViewer"]; } + - (WOComponent *)kolabNoteViewer { - return [self linkViewer]; + return [self textViewer]; // TODO } - (WOComponent *)kolabJournalViewer { - return [self linkViewer]; + return [self textViewer]; // TODO } - (WOComponent *)kolabDistributionListViewer { - return [self linkViewer]; + return [self textViewer]; // TODO } /* main viewer selection */ diff --git a/UI/MailPartViewers/Version b/UI/MailPartViewers/Version index 4d6c8a33..af42e0b0 100644 --- a/UI/MailPartViewers/Version +++ b/UI/MailPartViewers/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=19 +SUBMINOR_VERSION:=20 # v0.9.0 requires libNGiCal v4.5.53 # v0.9.1 requires libNGMime v4.5.213 diff --git a/UI/Templates/ChangeLog b/UI/Templates/ChangeLog index 4f2fce6a..a3c71786 100644 --- a/UI/Templates/ChangeLog +++ b/UI/Templates/ChangeLog @@ -1,30 +1,33 @@ 2005-07-30 Helge Hess - + + * MailerUI/UIxMailView.wox: do not show mail header when accessing a + Kolab mail object + * MailPartViewers/UIxMailPartImageViewer.wox: fixed 'title' attribute of image tag (now displays filename) - + * MailerUI/UIxMailMainFrame.wox: use 'view' instead of 'tb.view' to activate links - + 2005-07-26 Helge Hess - + * ContactsUI/UIxContactEditor.wox: removed copy-from-anais button - + * UIxAppointmentProposal.wox, UIxAppointmentEditor.wox: do not try to use Anais attendee selector (must be replaced) - + * MailerUI: use proper _wosid instead of 'sidinurl' in
tags - + 2005-07-22 Marcus Mueller - + * UIxMailPanelFrame.wox: added MailerUI.SOGo strings table for error messages - + * UIxMailEditor.wox: added inclusion of layout2or3_xlib.js and added a new id to compose_table - + 2005-07-21 Marcus Mueller - + * UIxCalDayOverview.wox, UIxCalDayChartview.wox, UIxCalDayListview.wox, UIxCalMonthOverview.wox: reworked the style bindings diff --git a/UI/Templates/MailPartViewers/GNUmakefile b/UI/Templates/MailPartViewers/GNUmakefile new file mode 100644 index 00000000..eacb1cac --- /dev/null +++ b/UI/Templates/MailPartViewers/GNUmakefile @@ -0,0 +1,12 @@ +# GNUstep makefile + +validate-wox: + xmllint --noout *.wox + +all :: validate-wox + +install :: all + +clean :: + +distclean :: clean diff --git a/UI/Templates/MailPartViewers/UIxKolabPartContactViewer.wox b/UI/Templates/MailPartViewers/UIxKolabPartContactViewer.wox new file mode 100644 index 00000000..378f4654 --- /dev/null +++ b/UI/Templates/MailPartViewers/UIxKolabPartContactViewer.wox @@ -0,0 +1,100 @@ + +
+
+ + : + + (ID: ) + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
:
:
:
:
:
:
:
:
:
:
:
:
+
+ + + +
+
+
diff --git a/UI/Templates/MailPartViewers/UIxKolabPartEventViewer.wox b/UI/Templates/MailPartViewers/UIxKolabPartEventViewer.wox new file mode 100644 index 00000000..02ff68a6 --- /dev/null +++ b/UI/Templates/MailPartViewers/UIxKolabPartEventViewer.wox @@ -0,0 +1,16 @@ + +
+
+ + Kolab Event + + +
+
+
diff --git a/UI/Templates/MailPartViewers/UIxKolabPartTaskViewer.wox b/UI/Templates/MailPartViewers/UIxKolabPartTaskViewer.wox new file mode 100644 index 00000000..700d11e0 --- /dev/null +++ b/UI/Templates/MailPartViewers/UIxKolabPartTaskViewer.wox @@ -0,0 +1,16 @@ + +
+
+ + Kolab Task + + +
+
+
diff --git a/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox b/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox index e14df9df..22987fc7 100644 --- a/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox +++ b/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox @@ -8,6 +8,17 @@ > + +
+ Parsing Error + + The SOGo/SOPE iCalendar parser could not parse the body of this MIME part. + +
+
+
+ +
: @@ -181,6 +192,7 @@
+
+ + +