From: helge Date: Tue, 5 Oct 2004 12:22:31 +0000 (+0000) Subject: added some TB icons, added alternative viewer X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e6de3d50b6e996f8d5d4002a9e4eba92bfe3747;p=scalable-opengroupware.org added some TB icons, added alternative viewer git-svn-id: http://svn.opengroupware.org/SOGo/trunk@356 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index c7f2f4a3..7d4259c3 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,14 @@ +2004-10-05 Helge Hess + + * v0.9.18 + + * UIxMailPartViewer.m: added support methods for caches, added -sleep + method + + * added multipart/alternative viewer + + * added Thunderbird message read/unread icons + 2004-10-04 Helge Hess * fixed fetching of mails with only text content (v0.9.17) diff --git a/SOGo/UI/Mailer/GNUmakefile b/SOGo/UI/Mailer/GNUmakefile index 9a09fea5..aacadd4e 100644 --- a/SOGo/UI/Mailer/GNUmakefile +++ b/SOGo/UI/Mailer/GNUmakefile @@ -26,10 +26,11 @@ MailerUI_OBJC_FILES += \ UIxMailView.m \ UIxMailEditor.m \ \ - UIxMailPartViewer.m \ - UIxMailPartTextViewer.m \ - UIxMailPartImageViewer.m\ - UIxMailPartMixedViewer.m + UIxMailPartViewer.m \ + UIxMailPartTextViewer.m \ + UIxMailPartImageViewer.m \ + UIxMailPartMixedViewer.m \ + UIxMailPartAlternativeViewer.m \ MailerUI_RESOURCE_FILES += \ Version \ @@ -48,6 +49,7 @@ MailerUI_RESOURCE_FILES += \ UIxMailPartTextViewer.wox \ UIxMailPartMixedViewer.wox \ UIxMailPartImageViewer.wox \ + UIxMailPartAlternativeViewer.wox\ MailerUI_RESOURCE_FILES += \ uix.css \ @@ -59,6 +61,7 @@ MailerUI_RESOURCE_FILES += \ Images/tbtv_*.gif \ Images/icon_*.gif \ Images/tbtb_*.png \ + Images/message-mail*.png\ Images/lori_32x32.png \ MailerUI_LOCALIZED_RESOURCE_FILES += \ diff --git a/SOGo/UI/Mailer/Images/message-mail-read.png b/SOGo/UI/Mailer/Images/message-mail-read.png new file mode 100755 index 00000000..17d5784c Binary files /dev/null and b/SOGo/UI/Mailer/Images/message-mail-read.png differ diff --git a/SOGo/UI/Mailer/Images/message-mail.png b/SOGo/UI/Mailer/Images/message-mail.png new file mode 100755 index 00000000..c58e0993 Binary files /dev/null and b/SOGo/UI/Mailer/Images/message-mail.png differ diff --git a/SOGo/UI/Mailer/README b/SOGo/UI/Mailer/README index fe933316..9cbcaeb1 100644 --- a/SOGo/UI/Mailer/README +++ b/SOGo/UI/Mailer/README @@ -22,6 +22,16 @@ UIxMailView.wox Notes ===== +- we might want to bind the content viewers as SOPE methods to the mail class? + eg "viewTextPlain" + - this would not return a WOComponent, but a SoPageInvocation + - caching might be more difficult + - some 'reuse component' support in SoPageInvocation for stateless + components? + - watch nested calls + - for this we would need to add support for embedded calling of SOPE methods + ? + Bodystructures ============== diff --git a/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.m b/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.m new file mode 100644 index 00000000..95f5345e --- /dev/null +++ b/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.m @@ -0,0 +1,164 @@ +/* + Copyright (C) 2004 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" + +/* + UIxMailPartAlternativeViewer + + Display multipart/alternative parts. Most common application is for messages + which contain text/html and text/plain, but it is also used in other + contexts, eg in OGo appointment mails. + + TODO: We might want to give the user the possibility to access all parts + of the alternative set. +*/ + +@interface UIxMailPartAlternativeViewer : UIxMailPartViewer +{ + id childInfo; + unsigned int childIndex; +} + +@end + +#include "UIxMailRenderingContext.h" +#include "WOContext+UIxMailer.h" +#include "common.h" + +@implementation UIxMailPartAlternativeViewer + +- (void)dealloc { + [self->childInfo release]; + [super dealloc]; +} + +/* caches */ + +- (void)resetBodyInfoCaches { + [self->childInfo release]; self->childInfo = nil; + self->childIndex = 0; + [super resetBodyInfoCaches]; +} + +/* part selection */ + +- (NSArray *)childPartTypes { + NSMutableArray *types; + unsigned i, count; + NSArray *childParts; + + childParts = [[self bodyInfo] valueForKey:@"parts"]; + count = [childParts count]; + types = [NSMutableArray arrayWithCapacity:count]; + + for (i = 0; i < count; i++) { + NSString *mt, *st; + + mt = [[[childParts objectAtIndex:i] valueForKey:@"type"] lowercaseString]; + st = [[[childParts objectAtIndex:i] valueForKey:@"subtype"] + lowercaseString]; + mt = [[mt stringByAppendingString:@"/"] stringByAppendingString:st]; + [types addObject:mt ? mt : (id)[NSNull null]]; + } + return types; +} + +- (int)selectPartIndexFromTypes:(NSArray *)_types { + /* returns the index of the selected part or NSNotFound */ + unsigned i, count; + + if ((count = [_types count]) == 0) + return NSNotFound; + + /* we always choose text/plain if available */ + if ((i = [_types indexOfObject:@"text/plain"]) != NSNotFound) + return i; + + /* then we scan for other text types and choose the first one found */ + for (i = 0; i < count; i++) { + if ([(NSString *)[_types objectAtIndex:i] hasPrefix:@"text/"]) + return i; + } + + /* as a fallback, we select the first available part */ + return 0; +} + +- (void)selectChildInfo { + unsigned idx; + + [self->childInfo release]; self->childInfo = nil; + self->childIndex = 0; + + idx = [self selectPartIndexFromTypes:[self childPartTypes]]; + if (idx == NSNotFound) { + [self logWithFormat:@"ERROR: could not select a part of types: %@", + [self childPartTypes]]; + return; + } + + self->childIndex = idx + 1; + self->childInfo = + [[[[self bodyInfo] valueForKey:@"parts"] objectAtIndex:idx] retain]; +} + +/* accessors */ + +- (id)childInfo { + if (self->childInfo == nil) + [self selectChildInfo]; + + return self->childInfo; +} + +- (unsigned int)childIndex { + if (self->childIndex == 0) + [self selectChildInfo]; + + return self->childIndex - 1; +} + +- (NSString *)childPartName { + unsigned char buf[8]; + sprintf(buf, "%d", [self childIndex] + 1); + return [NSString stringWithCString:buf]; +} + +- (id)childPartPath { + NSArray *pp; + + pp = [self partPath]; + return [pp count] > 0 + ? [pp arrayByAddingObject:[self childPartName]] + : [NSArray arrayWithObject:[self childPartName]]; +} + +/* nested viewers */ + +- (id)contentViewerComponent { + id info; + + info = [self childInfo]; + return [[[self context] mailRenderingContext] viewerForBodyInfo:info]; +} + +@end /* UIxMailPartAlternativeViewer */ diff --git a/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.wox b/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.wox new file mode 100644 index 00000000..8573896e --- /dev/null +++ b/SOGo/UI/Mailer/UIxMailPartAlternativeViewer.wox @@ -0,0 +1,13 @@ + +
+
+ +
+
diff --git a/SOGo/UI/Mailer/UIxMailPartMixedViewer.m b/SOGo/UI/Mailer/UIxMailPartMixedViewer.m index 4a7b9d36..099fbf00 100644 --- a/SOGo/UI/Mailer/UIxMailPartMixedViewer.m +++ b/SOGo/UI/Mailer/UIxMailPartMixedViewer.m @@ -40,11 +40,11 @@ [super dealloc]; } -/* notifications */ +/* caches */ -- (void)sleep { +- (void)resetBodyInfoCaches { [self->childInfo release]; self->childInfo = nil; - [super sleep]; + [super resetBodyInfoCaches]; } /* accessors */ diff --git a/SOGo/UI/Mailer/UIxMailPartViewer.h b/SOGo/UI/Mailer/UIxMailPartViewer.h index 9e1f6f55..a5551f08 100644 --- a/SOGo/UI/Mailer/UIxMailPartViewer.h +++ b/SOGo/UI/Mailer/UIxMailPartViewer.h @@ -49,6 +49,11 @@ - (NSData *)flatContent; +/* caches */ + +- (void)resetPathCaches; +- (void)resetBodyInfoCaches; + @end #endif /* __Mailer_UIxMailPartViewer_H__ */ diff --git a/SOGo/UI/Mailer/UIxMailPartViewer.m b/SOGo/UI/Mailer/UIxMailPartViewer.m index a043481c..e172aac4 100644 --- a/SOGo/UI/Mailer/UIxMailPartViewer.m +++ b/SOGo/UI/Mailer/UIxMailPartViewer.m @@ -33,10 +33,32 @@ [super dealloc]; } +/* caches */ + +- (void)resetPathCaches { + [self->flatContent release]; self->flatContent = nil; +} +- (void)resetBodyInfoCaches { +} + +/* notifications */ + +- (void)sleep { + [self resetPathCaches]; + [self resetBodyInfoCaches]; + [self->partPath release]; self->partPath = nil; + [self->bodyInfo release]; self->bodyInfo = nil; + [super sleep]; +} + /* accessors */ - (void)setPartPath:(NSArray *)_path { + if ([_path isEqual:self->partPath]) + return; + ASSIGN(self->partPath, _path); + [self resetPathCaches]; } - (NSArray *)partPath { return self->partPath; diff --git a/SOGo/UI/Mailer/UIxMailRenderingContext.h b/SOGo/UI/Mailer/UIxMailRenderingContext.h index 4f471161..672a5eb0 100644 --- a/SOGo/UI/Mailer/UIxMailRenderingContext.h +++ b/SOGo/UI/Mailer/UIxMailRenderingContext.h @@ -38,7 +38,8 @@ WOComponent *viewer; /* non-retained! */ WOContext *context; /* non-retained! */ NSDictionary *flatContents; /* IMAP4 name to NSData */ - + + WOComponent *alternativeViewer; WOComponent *mixedViewer; WOComponent *textViewer; WOComponent *imageViewer; diff --git a/SOGo/UI/Mailer/UIxMailRenderingContext.m b/SOGo/UI/Mailer/UIxMailRenderingContext.m index f30f2240..b7aac88a 100644 --- a/SOGo/UI/Mailer/UIxMailRenderingContext.m +++ b/SOGo/UI/Mailer/UIxMailRenderingContext.m @@ -40,6 +40,7 @@ } - (void)dealloc { + [self->alternativeViewer release]; [self->mixedViewer release]; [self->textViewer release]; [self->imageViewer release]; @@ -49,10 +50,11 @@ /* resetting state */ - (void)reset { - [self->flatContents release]; self->flatContents = nil; - [self->mixedViewer release]; self->mixedViewer = nil; - [self->textViewer release]; self->textViewer = nil; - [self->imageViewer release]; self->imageViewer = nil; + [self->flatContents release]; self->flatContents = nil; + [self->alternativeViewer release]; self->alternativeViewer = nil; + [self->mixedViewer release]; self->mixedViewer = nil; + [self->textViewer release]; self->textViewer = nil; + [self->imageViewer release]; self->imageViewer = nil; } /* fetching */ @@ -83,6 +85,14 @@ return self->mixedViewer; } +- (WOComponent *)alternativeViewer { + if (self->alternativeViewer == nil) { + self->alternativeViewer = + [[self->viewer pageWithName:@"UIxMailPartAlternativeViewer"] retain]; + } + return self->alternativeViewer; +} + - (WOComponent *)textViewer { if (self->textViewer == nil) { self->textViewer = @@ -110,10 +120,14 @@ return [self mixedViewer]; if ([st isEqualToString:@"signed"]) // TODO: temporary workaround return [self mixedViewer]; + if ([st isEqualToString:@"alternative"]) + return [self alternativeViewer]; } else if ([mt isEqualToString:@"text"]) { if ([st isEqualToString:@"plain"]) return [self textViewer]; + if ([st isEqualToString:@"html"]) + return [self textViewer]; // TODO: temporary workaround } else if ([mt isEqualToString:@"image"]) return [self imageViewer]; @@ -123,7 +137,8 @@ pgp-viewer */ } - + + // TODO: always fallback to octet viewer?! [self logWithFormat:@"ERROR: found no viewer for MIME type: %@/%@", mt, st]; return nil; } diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 33dfbe1b..cd35ad0f 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=17 +SUBMINOR_VERSION:=18 diff --git a/SOGo/UI/Mailer/mailer.css b/SOGo/UI/Mailer/mailer.css index 8a8186c3..1c95da26 100644 --- a/SOGo/UI/Mailer/mailer.css +++ b/SOGo/UI/Mailer/mailer.css @@ -197,7 +197,8 @@ span.mailer_datefield { div.mailer_readmailsubject { /* TODO: use proper read icon */ - background-image: url(tbtv_leaf_corner_17x17.gif); + /* background-image: url(tbtv_leaf_corner_17x17.gif); */ + background-image: url(message-mail-read.png); background-repeat: no-repeat; background-position: 0px 0px; padding-top: 1px; @@ -205,7 +206,8 @@ div.mailer_readmailsubject { } div.mailer_unreadmailsubject { /* TODO: use proper unread icon */ - background-image: url(tbtv_leaf_corner_17x17.gif); + /* background-image: url(tbtv_leaf_corner_17x17.gif); */ + background-image: url(message-mail.png); background-repeat: no-repeat; background-position: 0px 0px; padding-left: 20px; diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index 01e2f9a5..f272c668 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -38,6 +38,9 @@ "tbtb_search.png", "tbtb_trash.png", + "message-mail.png", + "message-mail-read.png", + "icon_mark_flagged.gif", "icon_mark_read.gif", "icon_mark_unflagged.gif",