Skip to content

Commit

Permalink
(fix) more fix regarding recurrence exceptions and body tags
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Jan 22, 2016
1 parent 5686e08 commit f34aa29
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions ActiveSync/iCalEvent+ActiveSync.m
Expand Up @@ -238,6 +238,34 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
if (![self recurrenceId] && [[self uid] length])
[s appendFormat: @"<UID xmlns=\"Calendar:\">%@</UID>", [[self uid] activeSyncRepresentationInContext: context]];

// Recurrence rules
if ([self isRecurrent])
[s appendString: [[[self recurrenceRules] lastObject] activeSyncRepresentationInContext: context]];

// Comment
o = [self comment];
//if (![self recurrenceId] && [o length])
if ([o length])
{
// It is very important here to NOT set <Truncated>0</Truncated> in the response,
// otherwise it'll prevent WP8 phones from sync'ing. See #3028 for details.
o = [o activeSyncRepresentationInContext: context];

if ([[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"2.5"])
{
[s appendFormat: @"<Body xmlns=\"Calendar:\">%@</Body>", o];
[s appendString: @"<BodyTruncated xmlns=\"Calendar:\">0</BodyTruncated>"];
}
else
{
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
[s appendFormat: @"<Type>%d</Type>", 1];
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", (int)[o length]];
[s appendFormat: @"<Data>%@</Data>", o];
[s appendString: @"</Body>"];
}
}

// Sensitivity
if ([[self accessClass] isEqualToString: @"PRIVATE"])
v = 2;
Expand Down Expand Up @@ -270,7 +298,7 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
[s appendString: [alarm activeSyncRepresentationInContext: context]];
}

// Recurrence rules
// Exceptions
if ([self isRecurrent])
{
NSMutableArray *components, *exdates;
Expand All @@ -279,8 +307,6 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context

unsigned int count, max, i;

[s appendString: [[[self recurrenceRules] lastObject] activeSyncRepresentationInContext: context]];

components = [NSMutableArray arrayWithArray: [[self parent] events]];
max = [components count];

Expand Down Expand Up @@ -343,29 +369,6 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
}
}

// Comment
o = [self comment];
if ([o length])
{
// It is very important here to NOT set <Truncated>0</Truncated> in the response,
// otherwise it'll prevent WP8 phones from sync'ing. See #3028 for details.
o = [o activeSyncRepresentationInContext: context];

if ([self recurrenceId] || [[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"2.5"])
{
[s appendFormat: @"<Body xmlns=\"Calendar:\">%@</Body>", o];
[s appendString: @"<BodyTruncated xmlns=\"Calendar:\">0</BodyTruncated>"];
}
else
{
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
[s appendFormat: @"<Type>%d</Type>", 1];
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", (int)[o length]];
[s appendFormat: @"<Data>%@</Data>", o];
[s appendString: @"</Body>"];
}
}

if (![self recurrenceId])
[s appendFormat: @"<NativeBodyType xmlns=\"AirSyncBase:\">%d</NativeBodyType>", 1];

Expand Down

0 comments on commit f34aa29

Please sign in to comment.