From 3731819e1565a6198237218dff078047628b1316 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 5 Feb 2015 16:21:27 -0500 Subject: [PATCH] Added patch from tfu for #2995 --- ActiveSync/SOGoMailObject+ActiveSync.m | 85 ++++++++++++++++++++ Documentation/SOGoInstallationGuide.asciidoc | 4 + NEWS | 3 + 3 files changed, 92 insertions(+) diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index 6cc06e3d0..e7797dfeb 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -47,6 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import #import +#import #import #import @@ -57,6 +58,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import + +#import + #include "iCalTimeZone+ActiveSync.h" #include "NSData+ActiveSync.h" #include "NSDate+ActiveSync.h" @@ -774,6 +779,27 @@ struct GlobalObjectId { [s appendString: @""]; [s appendFormat: @"%d", ([self flagged] ? 2 : 0)]; [s appendString: @""]; + + + // Categroies/Labels + NSEnumerator *categories; + categories = [[[self fetchCoreInfos] objectForKey: @"flags"] objectEnumerator]; + + if (categories) + { + NSString *currentFlag; + NSDictionary *v; + + v = [[[context activeUser] userDefaults] mailLabelsColors]; + + [s appendFormat: @""]; + while ((currentFlag = [categories nextObject])) + { + if ([[v objectForKey: currentFlag] objectAtIndex:0]) + [s appendFormat: @"%@", [[[v objectForKey: currentFlag] objectAtIndex:0] activeSyncRepresentationInContext: context]]; + } + [s appendFormat: @""]; + } // FIXME - support these in the future //[s appendString: @"foobar"]; @@ -836,6 +862,65 @@ struct GlobalObjectId { else [self removeFlags: @"seen"];; } + + if ((o = [theValues objectForKey: @"Categories"])) + { + NSEnumerator *categories; + NSString *currentFlag; + NSDictionary *v; + + v = [[[context activeUser] userDefaults] mailLabelsColors]; + + // add categories/labels sent from client + if ([o isKindOfClass: [NSArray class]]) + { + NSEnumerator *enumerator; + NSMutableArray *labels; + NSEnumerator *flags; + id key; + + labels = [NSMutableArray array]; + + enumerator = [v keyEnumerator]; + flags = [o objectEnumerator]; + + while ((currentFlag = [flags nextObject])) + { + while ((key = [enumerator nextObject])) + { + if (([currentFlag isEqualToString:[[v objectForKey:key] objectAtIndex:0]])) + { + [labels addObject: key]; + break; + } + } + } + + [self addFlags: [labels componentsJoinedByString: @" "]]; + } + + categories = [[[self fetchCoreInfos] objectForKey: @"flags"] objectEnumerator]; + + // remove all categories/labels from server which were not it the list sent from client + if (categories) + { + while ((currentFlag = [categories nextObject])) + { + // only deal with lables and don't touch flags like seen and flagged + if (([v objectForKey: currentFlag])) + { + if (![o isKindOfClass: [NSArray class]]) + { + [self removeFlags: currentFlag]; + } + else if (([o indexOfObject: [[v objectForKey:currentFlag] objectAtIndex:0]] == NSNotFound)) + { + [self removeFlags: currentFlag]; + } + } + } + } + } } @end diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index e88affe42..b07eedfa2 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2421,6 +2421,10 @@ Please be aware of the following limitations: solution is to configure Outlook to use a LDAP server (over SSL) with authentication. Outlook 2013 also does not seem to support multiple address books over ActiveSync. +* To successfully synchronize Outlook email categories, a corresponding +mail label (Preferences->Mail Options) has to be created manually in SOGo +for each label defined in Outlook. The name in SOGo and in Outlook must be +identical. * Make sure you do not use a self-signed certificate. While this will work, Outlook will work intermittently as it will raise popups for certificate validation, sometimes in background, preventing the user to diff --git a/NEWS b/NEWS index 6ddb317a6..1fc92edbf 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ 2.2.16 (2015-02-DD) ------------------- +Enhancements + - added support for email categories using EAS (#2995) + Bug fixes - (regression) fixed sending a message when mail module is not active (#3088) - mail lables with blanks are not handled correctly (#3078)