View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002808 | SOGo | ActiveSync | public | 2014-06-07 22:54 | 2014-06-09 13:26 |
Reporter | tfu | Assigned To | ludovic | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 2.2.4 | ||||
Target Version | 2.2.6 | Fixed in Version | 2.2.6 | ||
Summary | 0002808: cannot open attachments on old AS clients | ||||
Description | AS clients supporting version 12 and older need GetAttachment to open eMail attachments. Attached patch implements this function. Basically it is a copy of ItemOperation with the difference in the way it sends the result to the client. | ||||
Tags | No tags attached. | ||||
0003-GetAttachment.patch (5,426 bytes)
From e53954d44f0c9dc2ca67b36df9ba9080f0b3d4a1 Mon Sep 17 00:00:00 2001 From: root <root@example.com> Date: Sun, 8 Jun 2014 00:42:15 +0200 Subject: [PATCH 3/3] GetAttachment --- ActiveSync/NSString+ActiveSync.h | 1 + ActiveSync/NSString+ActiveSync.m | 17 ++++++++++++ ActiveSync/SOGoActiveSyncDispatcher.m | 49 +++++++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/ActiveSync/NSString+ActiveSync.h b/ActiveSync/NSString+ActiveSync.h index f3f95b0..172d71e 100644 --- a/ActiveSync/NSString+ActiveSync.h +++ b/ActiveSync/NSString+ActiveSync.h @@ -47,6 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (NSCalendarDate *) calendarDate; - (NSString *) deviceId; - (NSString *) deviceType; +- (NSString *) attachmentName; - (NSString *) command; - (NSData *) convertHexStringToBytes; diff --git a/ActiveSync/NSString+ActiveSync.m b/ActiveSync/NSString+ActiveSync.m index b1fba0f..3d1a2b8 100644 --- a/ActiveSync/NSString+ActiveSync.m +++ b/ActiveSync/NSString+ActiveSync.m @@ -186,6 +186,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. return s; } +// This method extracts the "AttachmentName" from a URI: +// +// /SOGo/Microsoft-Server-ActiveSync?Cmd=GetAttachment&User=sogo&DeviceId=HTCa04b4932597acd3f2dc1a918b9728&DeviceType=htcvision&AttachmentName=mail/TestFldr/8/2 +// +- (NSString *) attachmentName +{ + NSString *s; + + s = [self _valueForParameter: @"ATTACHMENTNAME="]; + + if (!s) + s = @"Unknown"; + + return s; +} + + // // // diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 9c52d79..395459e 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -781,7 +781,51 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (void) processGetAttachment: (id <DOMElement>) theDocumentElement inResponse: (WOResponse *) theResponse { + NSString *fileReference, *realCollectionId; + SOGoMicrosoftActiveSyncFolderType folderType; + + fileReference = [context objectForKey: @"AttachmentName"]; + + realCollectionId = [fileReference realCollectionIdWithFolderType: &folderType]; + + if (folderType == ActiveSyncMailFolder) + { + id currentFolder, currentCollection, currentBodyPart; + NSString *folderName, *messageName, *pathToPart; + SOGoMailAccounts *accountsFolder; + SOGoUserFolder *userFolder; + SOGoMailObject *mailObject; + + NSRange r1, r2; + + r1 = [realCollectionId rangeOfString: @"/"]; + r2 = [realCollectionId rangeOfString: @"/" options: 0 range: NSMakeRange(NSMaxRange(r1)+1, [realCollectionId length]-NSMaxRange(r1)-1)]; + + folderName = [realCollectionId substringToIndex: r1.location]; + messageName = [realCollectionId substringWithRange: NSMakeRange(NSMaxRange(r1), r2.location-r1.location-1)]; + pathToPart = [realCollectionId substringFromIndex: r2.location+1]; + + userFolder = [[context activeUser] homeFolderInContext: context]; + accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO]; + currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO]; + + currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", folderName] + inContext: context + acquire: NO]; + + mailObject = [currentCollection lookupName: messageName inContext: context acquire: NO]; + currentBodyPart = [mailObject lookupImap4BodyPartKey: pathToPart inContext: context]; + + [theResponse setHeader: [NSString stringWithFormat: @"%@/%@", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]] + forKey: @"Content-Type"]; + + [theResponse setContent: [currentBodyPart fetchBLOB] ]; + } + else + { + [theResponse setStatus: 500]; + } } // @@ -892,7 +936,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. fileReference = [[[(id)[theDocumentElement getElementsByTagName: @"FileReference"] lastObject] textValue] stringByUnescapingURL]; realCollectionId = [fileReference realCollectionIdWithFolderType: &folderType]; - realCollectionId = [self globallyUniqueIDToIMAPFolderName: realCollectionId type: folderType]; if (folderType == ActiveSyncMailFolder) { @@ -1827,6 +1870,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. deviceId = [[theRequest uri] deviceId]; [context setObject: deviceId forKey: @"DeviceId"]; [context setObject: [[theRequest uri] deviceType] forKey: @"DeviceType"]; + [context setObject: [[theRequest uri] attachmentName] forKey: @"AttachmentName"]; + cmdName = [[theRequest uri] command]; @@ -1870,7 +1915,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. { // We check if it's a Ping command with no body. // See http://msdn.microsoft.com/en-us/library/ee200913(v=exchg.80).aspx for details - if ([cmdName caseInsensitiveCompare: @"Ping"] != NSOrderedSame) + if ([cmdName caseInsensitiveCompare: @"Ping"] != NSOrderedSame && [cmdName caseInsensitiveCompare: @"GetAttachment"] != NSOrderedSame) return [NSException exceptionWithHTTPStatus: 500]; } -- 1.7.9.5 |
|
Patch applied: https://github.com/inverse-inc/sogo/commit/0f04be2bcb003ff0b0c1099c524dffa3b40d0181 Thanks! |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2014-06-07 22:54 | tfu | New Issue | |
2014-06-07 22:54 | tfu | File Added: 0003-GetAttachment.patch | |
2014-06-09 13:26 | ludovic | Target Version | => 2.2.6 |
2014-06-09 13:26 | ludovic | Note Added: 0007163 | |
2014-06-09 13:26 | ludovic | Status | new => resolved |
2014-06-09 13:26 | ludovic | Fixed in Version | => 2.2.6 |
2014-06-09 13:26 | ludovic | Resolution | open => fixed |
2014-06-09 13:26 | ludovic | Assigned To | => ludovic |