diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m
index f51151edf..9be2ebe62 100644
--- a/ActiveSync/SOGoActiveSyncDispatcher.m
+++ b/ActiveSync/SOGoActiveSyncDispatcher.m
@@ -2576,7 +2576,7 @@ static BOOL debugOn = NO;
NGMimeFileData *fdata;
NSException *error;
NSArray *attachmentKeys;
- NSMutableArray *attachments;
+ NSMutableArray *attachments, *references;
id body, bodyFromSmartForward, htmlPart, textPart;
NSString *fullName, *email, *charset, *s;
@@ -2615,7 +2615,25 @@ static BOOL debugOn = NO;
[map setObject: email forKey: @"from"];
if ([mailObject messageId])
- [map setObject: [mailObject messageId] forKey: @"in-reply-to"];
+ {
+ [map setObject: [mailObject messageId] forKey: @"in-reply-to"];
+
+ references = [[[[[mailObject mailHeaders] objectForKey: @"references"] componentsSeparatedByString: @" "] mutableCopy] autorelease];
+ if ([references count] > 0)
+ {
+ // If there are more than ten identifiers listed, we eliminate the second one.
+ if ([references count] >= 10)
+ [references removeObjectAtIndex: 1];
+
+ [references addObject: [mailObject messageId]];
+
+ [map setObject: [references componentsJoinedByString:@" "] forKey: @"references"];
+ }
+ else
+ {
+ [map setObject: [mailObject messageId] forKey: @"references"];
+ }
+ }
messageToSend = [[[NGMimeMessage alloc] initWithHeader: map] autorelease];
body = [[[NGMimeMultipartBody alloc] initWithPart: messageToSend] autorelease];
diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m
index 3e6de011b..6b2e1b03a 100644
--- a/ActiveSync/SOGoMailObject+ActiveSync.m
+++ b/ActiveSync/SOGoMailObject+ActiveSync.m
@@ -550,6 +550,28 @@ struct GlobalObjectId {
return d;
}
+
+- (NSString *) _getNormalizedSubject
+{
+ NSString *subject;
+ NSUInteger colIdx;
+ NSString *stringValue;
+
+ subject = [[self subject] decodedHeader];
+
+ colIdx = [subject rangeOfString: @":" options:NSBackwardsSearch].location;
+ if (colIdx != NSNotFound && colIdx + 1 < [subject length])
+ stringValue = [[subject substringFromIndex: colIdx + 1] stringByTrimmingLeadSpaces];
+ else
+ stringValue = subject;
+
+ if (!stringValue)
+ stringValue = @"";
+
+ return stringValue;
+}
+
+
//
//
//
@@ -663,7 +685,7 @@ struct GlobalObjectId {
if (value)
{
[s appendFormat: @"%@", [value activeSyncRepresentationInContext: context]];
- [s appendFormat: @"%@", [value activeSyncRepresentationInContext: context]];
+ [s appendFormat: @"%@", [[self _getNormalizedSubject] activeSyncRepresentationInContext: context]];
}
// DateReceived
@@ -1049,7 +1071,13 @@ struct GlobalObjectId {
if ([[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"14.0"] ||
[[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"14.1"])
{
- if ([self inReplyTo])
+ NSString *reference;
+
+ reference = [[[[self mailHeaders] objectForKey: @"references"] componentsSeparatedByString: @" "] objectAtIndex: 0];
+
+ if ([reference length] > 0)
+ [s appendFormat: @"%@", [[reference dataUsingEncoding: NSUTF8StringEncoding] activeSyncRepresentationInContext: context]];
+ else if ([self inReplyTo])
[s appendFormat: @"%@", [[[self inReplyTo] dataUsingEncoding: NSUTF8StringEncoding] activeSyncRepresentationInContext: context]];
else if ([self messageId])
[s appendFormat: @"%@", [[[self messageId] dataUsingEncoding: NSUTF8StringEncoding] activeSyncRepresentationInContext: context]];
diff --git a/NEWS b/NEWS
index eb6c90df1..eca77a380 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ Bug fixes
- Android EAS Lollipop fixes (#3268 and #3269)
- improved EAS email flagging handling (#3140)
- fixed computation of GlobalObjectId (#3235)
+ - fixed EAS conversation ID issues on BB10 (#3152)
2.3.0 (2015-06-01)
-------------------