From 1e6de3d50b6e996f8d5d4002a9e4eba92bfe3747 Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 5 Oct 2004 12:22:31 +0000 Subject: [PATCH] added some TB icons, added alternative viewer git-svn-id: http://svn.opengroupware.org/SOGo/trunk@356 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Mailer/ChangeLog | 11 ++ SOGo/UI/Mailer/GNUmakefile | 11 +- SOGo/UI/Mailer/Images/message-mail-read.png | Bin 0 -> 818 bytes SOGo/UI/Mailer/Images/message-mail.png | Bin 0 -> 626 bytes SOGo/UI/Mailer/README | 10 ++ SOGo/UI/Mailer/UIxMailPartAlternativeViewer.m | 164 ++++++++++++++++++ .../Mailer/UIxMailPartAlternativeViewer.wox | 13 ++ SOGo/UI/Mailer/UIxMailPartMixedViewer.m | 6 +- SOGo/UI/Mailer/UIxMailPartViewer.h | 5 + SOGo/UI/Mailer/UIxMailPartViewer.m | 22 +++ SOGo/UI/Mailer/UIxMailRenderingContext.h | 3 +- SOGo/UI/Mailer/UIxMailRenderingContext.m | 25 ++- SOGo/UI/Mailer/Version | 2 +- SOGo/UI/Mailer/mailer.css | 6 +- SOGo/UI/Mailer/product.plist | 3 + 15 files changed, 265 insertions(+), 16 deletions(-) create mode 100755 SOGo/UI/Mailer/Images/message-mail-read.png create mode 100755 SOGo/UI/Mailer/Images/message-mail.png create mode 100644 SOGo/UI/Mailer/UIxMailPartAlternativeViewer.m create mode 100644 SOGo/UI/Mailer/UIxMailPartAlternativeViewer.wox 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 0000000000000000000000000000000000000000..17d5784cca5440b752ecfba3e8f32db07ca29a0e GIT binary patch literal 818 zcmV-21I_%2P){g68v>2KpM(!A5y4v z5E7j~$UAL4J>26CaeA6wueY<5fj{%fn39sl=b2hck>TU3UNhBSgGruVa1QpN``cHv zx3qle{>7cxd*V_h%jOt_QG;8RwlF_$QW7v=3JlWt`gl*73Plz{Wy!^$3OI)Y?aj?% zd&jq|I-A>t)YR0@p=wCe+q>E}J|ufxY*b8FkARL&2Pkiczt_J_G5?7XT2bwUgh@MRI7YfN6cegfVItR1qI)2JZyFz9Or~2iVQL&8L&Gf z1oH1ef7I~0q?Aphx#}(ztQZ`h&gdP;5lRNgkt`u6=HQBmc&G&B(DUz53fn?C^SC8t}|%{Qde?=E{oskx@nQ`$IFZ~s3YT{5D#?LzlJ(= z8QdrPVBlRL)+8pt(}N98aw6YYgxzP;4Wy>%I$gdwkxhi%5EMuPkH@D@LK7B>u(fe$ zGnvq0s)p|Pkx?;30lBw}vFC!(Kuiy=(&&Ulmsn;WY726q4h%rZ%2<{xxCGX^dVDuq z5FNi39#CAdY-1_*UAbc*Z}KnGSlw<`{s0=D6kyh(#n6OkN5#V|;HTA!_NLERx+0wI z21S;!4Es}a4CH0bMH;X|dgiAT!jy1QYuSfSO}Tb9Ey#- w5AwWpH2bMx=w}LMh-YAp!wvs`hQ?<34Z8)#g+NKTq5uE@07*qoM6N<$f|jF#y8r+H literal 0 HcmV?d00001 diff --git a/SOGo/UI/Mailer/Images/message-mail.png b/SOGo/UI/Mailer/Images/message-mail.png new file mode 100755 index 0000000000000000000000000000000000000000..c58e0993a311dad840ab423f2d8f334782934cd9 GIT binary patch literal 626 zcmV-&0*(ENP)Y|%&x``4>X#0xHWwx}j zQ4<{%mSqKnrm|pWq%%wVv2<=Z+`jGGPG^&ipmq`6b>QKBUU;AP=bZNt{No}2L4pZS zhd(9=(pXf0z`!^XJO$y8eiS?(32r}ru7rGWJL$scV#rpnMYdSNa>f7}o408mpSM&% zBpAT=AvfGTgV=Vm?g$xu<)ACn26!Lap{lG#jzpSK%>S6dNOva+^m;sW+{3O@7tQ3| zi`!JQZa3y;zGBdI3)-!Fu_SldZ{l#k2al@_g@!VSmx^%LVu$hcC5{X|v(mz{>SSPW z`U?i^O(>~30I@7DEe`po(PwLgZsU4LbJ>^z4@cu2)SkJ_5l>eW)m9kOZTmluquYD| zRYy-iBF{s}H-$$g6H1LcAz!ITiV@{uYiz^5vke@1{ooqaZP=3(N5gY?-e7`UslsS) z4Qf9f7ys4Si)PvRRU5%Y7WIzsZqar-`m9--NfFPACmk$*K?{=~fff zQatc&67Sy(qexqT7V8rnGPiQ%rM;f!ugZr^U4$I5D5E&ZnGMa(!te9L)!v80SM3~m zYCRuBEG|lISf&k3Y^d;y9}0(sW6kYc;xDKfHZy1#vi{;5B%W>fCztP4N->$d8~^|S M07*qoM6N<$f&gkEa{vGU literal 0 HcmV?d00001 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", -- 2.39.5