diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index 7b0a008a4..58dca5cf1 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -761,7 +761,7 @@ struct GlobalObjectId { // Flags [s appendString: @""]; - [s appendFormat: @"%d", 0]; + [s appendFormat: @"%d", ([self flagged] ? 2 : 0)]; [s appendString: @""]; // FIXME - support these in the future @@ -799,10 +799,21 @@ struct GlobalObjectId { if ((o = [theValues objectForKey: @"Flag"])) { - o = [o objectForKey: @"FlagStatus"]; - - if ([o intValue]) - [self addFlags: @"\\Flagged"]; + // We must handle empty flags -> {Flag = ""; } - some ActiveSync clients, like the HTC Desire + // will send an empty Flag message when "unflagging" a mail. + if (([o isKindOfClass: [NSMutableDictionary class]])) + { + if ((o = [o objectForKey: @"FlagStatus"])) + { + // 0 = The flag is cleared. + // 1 = The status is set to complete. + // 2 = The status is set to active. + if (([o isEqualToString: @"2"])) + [self addFlags: @"\\Flagged"]; + else + [self removeFlags: @"\\Flagged"]; + } + } else [self removeFlags: @"\\Flagged"]; } diff --git a/NEWS b/NEWS index c6086a368..a76c2668a 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ Enhancements - implemented the GetAttachment ActiveSync command (#2808) Bug fixes - + - better handling of empty "Flag" messages over ActiveSync (#2806) 2.2.5 (2014-06-05) ------------------ diff --git a/SoObjects/Mailer/SOGoMailObject.h b/SoObjects/Mailer/SOGoMailObject.h index 46c1d7c14..af52334ee 100644 --- a/SoObjects/Mailer/SOGoMailObject.h +++ b/SoObjects/Mailer/SOGoMailObject.h @@ -114,6 +114,7 @@ NSArray *SOGoMailCoreInfoKeys; - (NSException *) removeFlags:(id)_f; - (BOOL) isNewMail; /* \Recent */ +- (BOOL) flagged; /* \Flagged */ - (BOOL) read; /* \Unseen */ - (BOOL) replied; /* \Answered */ - (BOOL) forwarded; /* $forwarded */ diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index f2fa35eac..f99bcf49d 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -1464,6 +1464,11 @@ static BOOL debugSoParts = NO; return [self _hasFlag: @"seen"]; } +- (BOOL) flagged +{ + return [self _hasFlag: @"flagged"]; +} + - (BOOL) replied { return [self _hasFlag: @"answered"];