mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-17 07:33:57 +00:00
feat(mail): Add 'View raw message' mail contextual option. This option open message in a popup without HTML mail CSS content modification.
This commit is contained in:
@@ -48,16 +48,34 @@
|
||||
*/
|
||||
|
||||
@interface UIxMailPartAlternativeViewer : UIxMailPartMixedViewer
|
||||
{
|
||||
BOOL rawContent;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIxMailPartAlternativeViewer
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
rawContent = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)activateRawContent
|
||||
{
|
||||
rawContent = YES;
|
||||
}
|
||||
|
||||
/* part selection */
|
||||
|
||||
- (NSArray *) childPartTypes
|
||||
@@ -206,6 +224,9 @@
|
||||
[viewer setAttachmentIds: attachmentIds];
|
||||
if ([self decodedFlatContent])
|
||||
[viewer setDecodedContent: [parts objectAtIndex: i]];
|
||||
|
||||
if ([viewer isKindOfClass:NSClassFromString(@"UIxMailPartHTMLViewer")] && rawContent)
|
||||
[viewer activateRawContent];
|
||||
[renderedParts addObject: [viewer renderedPart]];
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
{
|
||||
id handler;
|
||||
NSException *ex;
|
||||
BOOL rawContent;
|
||||
}
|
||||
|
||||
- (NSString *) flatContentAsString;
|
||||
- (void)activateRawContent;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -128,9 +128,11 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
BOOL inCSSDeclaration;
|
||||
BOOL hasEmbeddedCSS;
|
||||
xmlCharEncoding contentEncoding;
|
||||
BOOL rawContent;
|
||||
}
|
||||
|
||||
- (NSString *) result;
|
||||
- (void) activateRawContent;
|
||||
|
||||
@end
|
||||
|
||||
@@ -161,6 +163,7 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
ignoreTag = nil;
|
||||
attachmentIds = nil;
|
||||
contentEncoding = XML_CHAR_ENCODING_UTF8;
|
||||
rawContent = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -174,6 +177,11 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)activateRawContent
|
||||
{
|
||||
rawContent = YES;
|
||||
}
|
||||
|
||||
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
|
||||
{
|
||||
contentEncoding = newContentEncoding;
|
||||
@@ -376,7 +384,8 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
(*(currentChar-7) == 'p' || *(currentChar-7) == 'P') &&
|
||||
(*(currentChar-8) == 'm' || *(currentChar-8) == 'M') &&
|
||||
(*(currentChar-9) == 'i' || *(currentChar-9) == 'I') &&
|
||||
*(currentChar-10) == '!'))
|
||||
*(currentChar-10) == '!')
|
||||
&& !rawContent)
|
||||
{
|
||||
length = (currentChar - start);
|
||||
[declaration appendFormat: @"%@ !important;",
|
||||
@@ -759,11 +768,17 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
{
|
||||
handler = nil;
|
||||
ex = nil;
|
||||
rawContent = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)activateRawContent
|
||||
{
|
||||
rawContent = YES;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[handler release];
|
||||
@@ -805,6 +820,8 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
createXMLReaderForMimeType: @"text/html"];
|
||||
|
||||
handler = [_UIxHTMLMailContentHandler new];
|
||||
if (rawContent)
|
||||
[handler activateRawContent];
|
||||
[handler setAttachmentIds: attachmentIds];
|
||||
|
||||
// Some broken email messages have some additionnal content outside the main HTML tags which are
|
||||
@@ -920,6 +937,9 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
|
||||
if (!handler)
|
||||
[self _parseContent];
|
||||
|
||||
if (rawContent)
|
||||
return [handler result];
|
||||
|
||||
return _sanitizeHtmlForDisplay([handler result]);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,7 @@
|
||||
"Save As..." = "Save As...";
|
||||
"Print Preview" = "Print Preview";
|
||||
"View Message Source" = "View Message Source";
|
||||
"View raw message" = "View raw message";
|
||||
|
||||
/* Message view "more" menu: create an event from message */
|
||||
"Convert To Event" = "Convert To Event";
|
||||
|
||||
@@ -256,6 +256,7 @@
|
||||
"Save As..." = "Télécharger";
|
||||
"Print Preview" = "Aperçu avant impression";
|
||||
"View Message Source" = "Voir le code source";
|
||||
"View raw message" = "Voir le message brut";
|
||||
|
||||
/* Message view "more" menu: create an event from message */
|
||||
"Convert To Event" = "Convertir en événement";
|
||||
|
||||
@@ -274,6 +274,16 @@ static NSString *mailETag = nil;
|
||||
/* actions */
|
||||
|
||||
- (id <WOActionResults>) defaultAction
|
||||
{
|
||||
return [self view: NO];
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) viewRawAction
|
||||
{
|
||||
return [self view: YES];
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) view: (BOOL)raw
|
||||
{
|
||||
WOResponse *response;
|
||||
NSMutableDictionary *data;
|
||||
@@ -336,6 +346,12 @@ static NSString *mailETag = nil;
|
||||
}
|
||||
|
||||
viewer = [self contentViewerComponent]; // set attachmentIds for common parts
|
||||
|
||||
if (raw && ([viewer isKindOfClass: NSClassFromString(@"UIxMailPartHTMLViewer")]
|
||||
|| [viewer isKindOfClass: NSClassFromString(@"UIxMailPartAlternativeViewer")])) {
|
||||
// In this case, disable html mail content modification by SOGo
|
||||
[viewer activateRawContent];
|
||||
}
|
||||
renderedPart = [viewer renderedPart]; // set attachmentIds for encrypted & TNEF parts
|
||||
|
||||
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
|
||||
@@ -218,6 +218,11 @@
|
||||
pageName = "UIxMailView";
|
||||
actionName = "default";
|
||||
};
|
||||
viewRaw = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailView";
|
||||
actionName = "viewRaw";
|
||||
};
|
||||
sendMDN = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailView";
|
||||
|
||||
@@ -117,6 +117,12 @@
|
||||
<var:string label:value="View Message Source"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<md-menu-item ng-hide="::isPopup">
|
||||
<md-button label:aria-label="View raw message"
|
||||
ng-click="viewer.activateRawContent($event)">
|
||||
<var:string label:value="View raw message"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<md-menu-item>
|
||||
<md-button label:aria-label="Print..."
|
||||
ng-click="viewer.print()">
|
||||
|
||||
@@ -68,6 +68,19 @@
|
||||
stateMessage: stateMessage
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.messageRaw', {
|
||||
url: '/:messageId/viewRaw',
|
||||
views: {
|
||||
'message@': {
|
||||
templateUrl: 'UIxMailViewTemplate', // UI/Templates/MailerUI/UIxMailViewTemplate.wox
|
||||
controller: 'MessageController',
|
||||
controllerAs: 'viewer'
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
stateMessage: stateMessageRaw
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message.edit', {
|
||||
url: '/edit',
|
||||
views: {
|
||||
@@ -254,6 +267,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateMessageRaw.$inject = ['encodeUriFilter', '$stateParams', 'stateMailbox', 'Message'];
|
||||
function stateMessageRaw(encodeUriFilter, $stateParams, stateMailbox, Message) {
|
||||
var data, message;
|
||||
|
||||
data = { uid: $stateParams.messageId.toString() };
|
||||
message = new Message(stateMailbox.$account.id, stateMailbox, data);
|
||||
return message.$reload({ useCache: false, raw: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
|
||||
@@ -792,7 +792,7 @@
|
||||
* @function $reload
|
||||
* @memberof Message.prototype
|
||||
* @desc Fetch the viewable message body along with other metadata such as the list of attachments.
|
||||
* @param {object} [options] - set {useCache: true} to use already fetched data
|
||||
* @param {object} [options] - set {useCache: true} to use already fetched data, {raw: true} to remove web mail alteration
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.$reload = function (options) {
|
||||
@@ -813,7 +813,10 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
futureMessageData = Message.$$resource.fetch(this.$absolutePath(options), 'view');
|
||||
if (options && options.raw)
|
||||
futureMessageData = Message.$$resource.fetch(this.$absolutePath(options), 'viewRaw');
|
||||
else
|
||||
futureMessageData = Message.$$resource.fetch(this.$absolutePath(options), 'view');
|
||||
|
||||
return this.$unwrap(futureMessageData);
|
||||
};
|
||||
|
||||
@@ -544,6 +544,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
this.activateRawContent = function ($event) {
|
||||
this.openInPopup('viewRaw');
|
||||
};
|
||||
|
||||
this.print = function($event) {
|
||||
$window.print();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user