mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-05 11:35:26 +00:00
Monotone-Parent: 18f239a3de0b7ac267996e840fa462638dadaf29
Monotone-Revision: 7bd51d30db3d6ece97902530cd9a95f45334a530 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2007-12-10T22:34:12 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
NSArray *pathToPart;
|
||||
NSString *identifier;
|
||||
id partInfo;
|
||||
BOOL asAttachment;
|
||||
}
|
||||
|
||||
/* hierarchy */
|
||||
@@ -57,6 +58,8 @@
|
||||
|
||||
- (id) partInfo;
|
||||
- (NSData *) fetchBLOB;
|
||||
- (void) setAsAttachment;
|
||||
- (BOOL) asAttachment;
|
||||
|
||||
/* factory */
|
||||
|
||||
|
||||
@@ -63,13 +63,28 @@ static BOOL debugOn = NO;
|
||||
NSLog(@"Note(SOGoMailBodyPart): etag caching disabled!");
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
asAttachment = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[self->partInfo release];
|
||||
[self->identifier release];
|
||||
[self->pathToPart release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setAsAttachment
|
||||
{
|
||||
asAttachment = YES;
|
||||
}
|
||||
|
||||
|
||||
/* hierarchy */
|
||||
|
||||
- (SOGoMailObject *)mailObject {
|
||||
@@ -178,6 +193,8 @@ static BOOL debugOn = NO;
|
||||
/* lookup body part */
|
||||
if ([self isBodyPartKey:_key inContext:_ctx])
|
||||
obj = [self lookupImap4BodyPartKey:_key inContext:_ctx];
|
||||
else if ([_key isEqualToString: @"asAttachment"])
|
||||
[self setAsAttachment];
|
||||
/* should check whether such a filename exist in the attached names */
|
||||
if (!obj)
|
||||
obj = self;
|
||||
@@ -283,14 +300,18 @@ static BOOL debugOn = NO;
|
||||
|
||||
/* try type from body structure info */
|
||||
|
||||
parts = [self contentTypeForBodyPartInfo: [self partInfo]];
|
||||
contentType = [[parts componentsSeparatedByString: @";"] objectAtIndex: 0];
|
||||
|
||||
if (![contentType length])
|
||||
{
|
||||
extension = [[self nameInContainer] pathExtension];
|
||||
contentType = [self contentTypeForPathExtension: extension];
|
||||
}
|
||||
if (asAttachment)
|
||||
contentType = @"application/octet-stream";
|
||||
else {
|
||||
parts = [self contentTypeForBodyPartInfo: [self partInfo]];
|
||||
contentType = [[parts componentsSeparatedByString: @";"] objectAtIndex: 0];
|
||||
|
||||
if (![contentType length])
|
||||
{
|
||||
extension = [[self nameInContainer] pathExtension];
|
||||
contentType = [self contentTypeForPathExtension: extension];
|
||||
}
|
||||
}
|
||||
|
||||
return contentType;
|
||||
}
|
||||
@@ -301,7 +322,7 @@ static BOOL debugOn = NO;
|
||||
NSException *error;
|
||||
WOResponse *r;
|
||||
NSData *data;
|
||||
NSString *etag, *mimeType;
|
||||
NSString *etag, *mimeType, *fileName;
|
||||
|
||||
if ((error = [self matchesRequestConditionInContext:_ctx]) != nil) {
|
||||
// TODO: currently we fetch the body structure to get here - check this!
|
||||
@@ -333,6 +354,17 @@ static BOOL debugOn = NO;
|
||||
[r setHeader: mimeType forKey:@"content-type"];
|
||||
[r setHeader: [NSString stringWithFormat:@"%d", [data length]]
|
||||
forKey: @"content-length"];
|
||||
|
||||
if (asAttachment) {
|
||||
fileName = [[[self partInfo] objectForKey: @"parameterList"] objectForKey: @"name"];
|
||||
if (!fileName)
|
||||
fileName = [[[[self partInfo] objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"]
|
||||
objectForKey: @"filename"];
|
||||
if ([fileName length])
|
||||
[r setHeader: [NSString stringWithFormat: @"attachment; filename=%@", fileName]
|
||||
forKey: @"content-disposition"];
|
||||
}
|
||||
|
||||
if ((etag = [self davEntityTag]) != nil)
|
||||
[r setHeader:etag forKey:@"etag"];
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
"Create Filter From Message..." = "Create Filter From Message...";
|
||||
|
||||
/* Image Popup menu */
|
||||
"View Image" = "View Image";
|
||||
"Save Image" = "Save Image";
|
||||
|
||||
/* Mailbox popup menus */
|
||||
"Open in New Mail Window" = "Open in New Mail Window";
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
"Create Filter From Message..." = "Créer un filtre à partir du message...";
|
||||
|
||||
/* Image Popup menu */
|
||||
"View Image" = "Voir l'image";
|
||||
"Save Image" = "Enregistrer l'image";
|
||||
|
||||
/* Mailbox popup menus */
|
||||
"Open in New Mail Window" = "Ouvrir dans une nouvelle fenétre";
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
"Create Filter From Message..." = "Filter aus Nachricht erstellen...";
|
||||
|
||||
/* Image Popup menu */
|
||||
"View Image" = "View Image";
|
||||
"Save Image" = "Save Image";
|
||||
|
||||
/* Mailbox popup menus */
|
||||
"Open in New Mail Window" = "In neuem Fenster öffnen";
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
|
||||
<div class="menu" id="imageMenu">
|
||||
<ul>
|
||||
<li id="view_image"><var:string label:value="View Image"/></li>
|
||||
<li id="save_image"><var:string label:value="Save Image"/></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -985,9 +985,12 @@ function onMenuViewMessageSource(event) {
|
||||
preventDefault(event);
|
||||
}
|
||||
|
||||
function viewImage(event) {
|
||||
function saveImage(event) {
|
||||
var img = document.menuTarget;
|
||||
window.open(img.getAttribute("src"),'_blank','resizable=1');
|
||||
var url = img.getAttribute("src");
|
||||
var urlAsAttachment = url.replace(/(\/[^\/]*)$/,"/asAttachment$1");
|
||||
|
||||
window.location.href = urlAsAttachment;
|
||||
}
|
||||
|
||||
/* contacts */
|
||||
@@ -1742,7 +1745,7 @@ function getMenus() {
|
||||
"mark-menu", "-",
|
||||
null, null,
|
||||
onMenuDeleteMessage);
|
||||
menus["imageMenu"] = new Array(viewImage);
|
||||
menus["imageMenu"] = new Array(saveImage);
|
||||
menus["messageContentMenu"] = new Array(onMenuReplyToSender,
|
||||
onMenuReplyToAll,
|
||||
onMenuForwardMessage,
|
||||
|
||||
Reference in New Issue
Block a user