(fix) support EAS MIMETruncation
parent
d56d9f8b08
commit
42131c564a
|
@ -1388,7 +1388,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
changeDetected: (BOOL *) changeDetected
|
||||
maxSyncResponseSize: (int) theMaxSyncResponseSize
|
||||
{
|
||||
NSString *collectionId, *realCollectionId, *syncKey, *davCollectionTag, *bodyPreferenceType, *mimeSupport, *lastServerKey, *syncKeyInCache, *folderKey;
|
||||
NSString *collectionId, *realCollectionId, *syncKey, *davCollectionTag, *bodyPreferenceType, *mimeSupport, *mimeTruncation, *lastServerKey, *syncKeyInCache, *folderKey;
|
||||
NSMutableDictionary *folderMetadata, *folderOptions;
|
||||
NSMutableArray *supportedElements, *supportedElementNames;
|
||||
NSMutableString *changeBuffer, *commandsBuffer;
|
||||
|
@ -1508,13 +1508,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
bodyPreferenceType = @"4";
|
||||
|
||||
mimeSupport = [[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMESupport"];
|
||||
mimeTruncation = [[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMETruncation"];
|
||||
|
||||
if (!mimeSupport)
|
||||
mimeSupport = @"1";
|
||||
|
||||
if (!mimeTruncation)
|
||||
mimeTruncation = @"8";
|
||||
}
|
||||
else
|
||||
{
|
||||
mimeSupport = [[(id)[theDocumentElement getElementsByTagName: @"MIMESupport"] lastObject] textValue];
|
||||
mimeTruncation = [[(id)[theDocumentElement getElementsByTagName: @"MIMETruncation"] lastObject] textValue];
|
||||
|
||||
if (!mimeSupport)
|
||||
mimeSupport = [[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMESupport"];
|
||||
|
@ -1522,6 +1527,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
if (!mimeSupport)
|
||||
mimeSupport = @"0";
|
||||
|
||||
if (!mimeTruncation)
|
||||
mimeTruncation = [[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMETruncation"];
|
||||
|
||||
if (!mimeTruncation)
|
||||
mimeTruncation = @"8";
|
||||
|
||||
if ([mimeSupport isEqualToString: @"1"] && [bodyPreferenceType isEqualToString: @"4"])
|
||||
bodyPreferenceType = @"2";
|
||||
else if ([mimeSupport isEqualToString: @"2"] && [bodyPreferenceType isEqualToString: @"4"])
|
||||
|
@ -1529,12 +1540,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
else if ([mimeSupport isEqualToString: @"0"] && [bodyPreferenceType isEqualToString: @"4"])
|
||||
bodyPreferenceType = @"2";
|
||||
|
||||
|
||||
// Avoid writing to cache if there is nothing to change.
|
||||
if (![[[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"BodyPreferenceType"] isEqualToString: bodyPreferenceType] ||
|
||||
![[[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMESupport"] isEqualToString: mimeSupport])
|
||||
![[[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMESupport"] isEqualToString: mimeSupport] ||
|
||||
![[[folderMetadata objectForKey: @"FolderOptions"] objectForKey: @"MIMETruncation"] isEqualToString: mimeTruncation])
|
||||
{
|
||||
folderOptions = [[NSDictionary alloc] initWithObjectsAndKeys: mimeSupport, @"MIMESupport", bodyPreferenceType, @"BodyPreferenceType", nil];
|
||||
folderOptions = [[NSDictionary alloc] initWithObjectsAndKeys: mimeSupport, @"MIMESupport", mimeTruncation, @"MIMETruncation", bodyPreferenceType, @"BodyPreferenceType", nil];
|
||||
[folderMetadata setObject: folderOptions forKey: @"FolderOptions"];
|
||||
[self _setFolderMetadata: folderMetadata forKey: folderKey];
|
||||
}
|
||||
|
@ -1542,6 +1553,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
[context setObject: bodyPreferenceType forKey: @"BodyPreferenceType"];
|
||||
[context setObject: mimeSupport forKey: @"MIMESupport"];
|
||||
[context setObject: mimeTruncation forKey: @"MIMETruncation"];
|
||||
[context setObject: [folderMetadata objectForKey: @"SupportedElements"] forKey: @"SupportedElements"];
|
||||
|
||||
//
|
||||
|
|
|
@ -695,13 +695,14 @@ struct GlobalObjectId {
|
|||
NSMutableString *s;
|
||||
id value;
|
||||
|
||||
int preferredBodyType, mimeSupport, nativeBodyType;
|
||||
int preferredBodyType, mimeSupport, mimeTruncation, nativeBodyType;
|
||||
uint32_t v;
|
||||
|
||||
subtype = [[[self bodyStructure] valueForKey: @"subtype"] lowercaseString];
|
||||
|
||||
preferredBodyType = [[context objectForKey: @"BodyPreferenceType"] intValue];
|
||||
mimeSupport = [[context objectForKey: @"MIMESupport"] intValue];
|
||||
mimeTruncation = [[context objectForKey: @"MIMETruncation"] intValue];
|
||||
|
||||
s = [NSMutableString string];
|
||||
|
||||
|
@ -1007,9 +1008,64 @@ struct GlobalObjectId {
|
|||
AUTORELEASE(content);
|
||||
|
||||
content = [content activeSyncRepresentationInContext: context];
|
||||
truncated = 0;
|
||||
|
||||
len = [content length];
|
||||
truncated = 1;
|
||||
|
||||
// We handle MIMETruncation
|
||||
switch (mimeTruncation)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
content = @"";
|
||||
len = 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
content = [content substringToIndex: 4096];
|
||||
len = 4096;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
content = [content substringToIndex: 5120];
|
||||
len = 5120;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
content = [content substringToIndex: 7168];
|
||||
len = 7168;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
content = [content substringToIndex: 10240];
|
||||
len = 10240;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
content = [content substringToIndex: 20480];
|
||||
len = 20480;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
{
|
||||
content = [content substringToIndex: 51200];
|
||||
len = 51200;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
{
|
||||
content = [content substringToIndex: 102400];
|
||||
len = 102400;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
default:
|
||||
truncated = 0;
|
||||
}
|
||||
|
||||
if ([[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"2.5"])
|
||||
{
|
||||
|
@ -1031,12 +1087,8 @@ struct GlobalObjectId {
|
|||
|
||||
[s appendFormat: @"<Truncated>%d</Truncated>", truncated];
|
||||
[s appendFormat: @"<Preview></Preview>"];
|
||||
|
||||
if (!truncated)
|
||||
{
|
||||
[s appendFormat: @"<Data>%@</Data>", content];
|
||||
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", len];
|
||||
}
|
||||
[s appendString: @"</Body>"];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue