(feat) new viewer handler for encrypted emails

pull/239/head
Ludovic Marcotte 2017-12-23 08:59:32 -05:00
parent 72273bf454
commit 3f95d53de8
2 changed files with 26 additions and 20 deletions

View File

@ -1,20 +1,21 @@
/* /*
Copyright (C) 2005-2017 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org. This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under SOGo 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 the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any Free Software Foundation; either version 2, or (at your option) any
later version. later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details. License for more details.
You should have received a copy of the GNU Lesser General Public 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 License along withS OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. 02111-1307, USA.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2007-2013 Inverse inc. Copyright (C) 2007-2017 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo. This file is part of SOGo.
@ -125,6 +125,11 @@ static BOOL showNamedTextAttachmentsInline = NO;
return [viewer pageWithName: @"UIxMailPartMixedViewer"]; return [viewer pageWithName: @"UIxMailPartMixedViewer"];
} }
- (WOComponent *) encryptedViewer
{
return [viewer pageWithName: @"UIxMailPartEncryptedViewer"];
}
- (WOComponent *) signedViewer - (WOComponent *) signedViewer
{ {
/* Note: we cannot cache the multipart viewers, because it can be nested */ /* Note: we cannot cache the multipart viewers, because it can be nested */
@ -156,11 +161,7 @@ static BOOL showNamedTextAttachmentsInline = NO;
- (WOComponent *) htmlViewer - (WOComponent *) htmlViewer
{ {
id o; return [viewer pageWithName: @"UIxMailPartHTMLViewer"];
o = [viewer pageWithName: @"UIxMailPartHTMLViewer"];
return o;
} }
- (WOComponent *) messageViewer - (WOComponent *) messageViewer
@ -198,13 +199,13 @@ static BOOL showNamedTextAttachmentsInline = NO;
/* this is used by mail-delivery reports */ /* this is used by mail-delivery reports */
return [self mixedViewer]; return [self mixedViewer];
} }
else if ([mt isEqualToString:@"text"]) else if ([mt isEqualToString: @"text"])
{ {
if ([st isEqualToString:@"plain"] || [st isEqualToString:@"html"]) { if ([st isEqualToString: @"plain"] || [st isEqualToString: @"html"]) {
if (!showNamedTextAttachmentsInline && [self _shouldDisplayAsAttachment: _info textPart:YES]) if (!showNamedTextAttachmentsInline && [self _shouldDisplayAsAttachment: _info textPart:YES])
return [self linkViewer]; return [self linkViewer];
return [st isEqualToString:@"html"] return [st isEqualToString: @"html"]
? [self htmlViewer] : [self textViewer]; ? [self htmlViewer] : [self textViewer];
} }
@ -214,7 +215,7 @@ static BOOL showNamedTextAttachmentsInline = NO;
// TIFF files aren't well-supported and Thunderbird sometimes send PDF // TIFF files aren't well-supported and Thunderbird sometimes send PDF
// files over as image/pdf ! // files over as image/pdf !
if ([mt isEqualToString:@"image"] && if ([mt isEqualToString: @"image"] &&
!([st isEqualToString: @"tiff"] || [st isEqualToString: @"pdf"])) !([st isEqualToString: @"tiff"] || [st isEqualToString: @"pdf"]))
{ {
if ([self _shouldDisplayAsAttachment: _info textPart: NO]) if ([self _shouldDisplayAsAttachment: _info textPart: NO])
@ -223,11 +224,11 @@ static BOOL showNamedTextAttachmentsInline = NO;
return [self imageViewer]; return [self imageViewer];
} }
if ([mt isEqualToString:@"message"] && [st isEqualToString:@"rfc822"]) if ([mt isEqualToString: @"message"] && [st isEqualToString: @"rfc822"])
return [self messageViewer]; return [self messageViewer];
if ([mt isEqualToString:@"message"] && if ([mt isEqualToString: @"message"] &&
[st isEqualToString:@"delivery-status"]) { [st isEqualToString: @"delivery-status"]) {
/* /*
Content-Description: Delivery error report Content-Description: Delivery error report
Content-Type: message/delivery-status Content-Type: message/delivery-status
@ -245,21 +246,25 @@ static BOOL showNamedTextAttachmentsInline = NO;
return [self linkViewer]; return [self linkViewer];
} }
if ([mt isEqualToString:@"application"]) if ([mt isEqualToString: @"application"])
{ {
// octet-stream (generate download link?, autodetect type?) // octet-stream (generate download link?, autodetect type?)
if ([st isEqualToString:@"ics"]) /* Cooqle K4lendahr - Google Calendar */ if ([st isEqualToString:@"ics"]) /* Cooqle K4lendahr - Google Calendar */
return [self iCalViewer]; return [self iCalViewer];
if ([st isEqualToString: @"x-pkcs7-mime"] ||
[st isEqualToString: @"pkcs7-mime"])
return [self encryptedViewer];
#if 0 /* the link viewer looks better than plain text ;-) */ #if 0 /* the link viewer looks better than plain text ;-) */
if ([st isEqualToString:@"pgp-signature"]) // TODO: real PGP viewer if ([st isEqualToString: @"pgp-signature"]) // TODO: real PGP viewer
return [self textViewer]; return [self textViewer];
#endif #endif
} }
// TODO: always fallback to octet viewer?! // TODO: always fallback to octet viewer?!
#if 1 #if 1
[self errorWithFormat:@"found no viewer for MIME type: %@/%@", mt, st]; [self errorWithFormat: @"found no viewer for MIME type: %@/%@", mt, st];
#endif #endif
return [self linkViewer]; return [self linkViewer];