diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 512e7a99e..2facf1276 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -718,8 +718,8 @@ void handle_eas_terminate(int signum) - (void) _flattenFolders: (NSArray *) theFolders into: (NSMutableArray *) theTarget - parent: (NSString *) theParent - parentType: (NSString *) theParentType + parent: (NSDictionary *) theParent + existingParent: (NSString *) theExistingParent { NSArray *o; int i; @@ -728,16 +728,30 @@ void handle_eas_terminate(int signum) for (i = 0; i < [theFolders count]; i++) { - if (theParent && ![theParentType isEqualToString: @"additional"]) - [[theFolders objectAtIndex: i] setObject: theParent forKey: @"parent"]; - - if ([theParentType isEqualToString: @"additional"]) - [[theFolders objectAtIndex: i] setObject: [[theFolders objectAtIndex: i] objectForKey: @"path"] forKey: @"name"]; + if ([theParent objectForKey: @"path"] && ![[theParent objectForKey: @"type"] isEqualToString: @"additional"]) + { + [[theFolders objectAtIndex: i] setObject: [theParent objectForKey: @"path"] forKey: @"parent"]; + theExistingParent = [theParent objectForKey: @"path"]; + } + else if (theExistingParent) + { + [[theFolders objectAtIndex: i] setObject: theExistingParent forKey: @"parent"]; + [[theFolders objectAtIndex: i] setObject: + [[[[theFolders objectAtIndex: i] objectForKey: @"path"] substringFromIndex: [theExistingParent length]+1]stringByReplacingOccurrencesOfString:@"/" withString:@"."] + forKey: @"name"]; + } + else if (![[[theFolders objectAtIndex: i] objectForKey: @"type"] isEqualToString: @"otherUsers"] && + ![[[theFolders objectAtIndex: i] objectForKey: @"type"] isEqualToString: @"shared"]) + { + [[theFolders objectAtIndex: i] setObject: + [[[theFolders objectAtIndex: i] objectForKey: @"path"] stringByReplacingOccurrencesOfString:@"/" withString:@"."] + forKey: @"name"]; + } o = [[theFolders objectAtIndex: i] objectForKey: @"children"]; if (o) - [self _flattenFolders: o into: theTarget parent: [[theFolders objectAtIndex: i] objectForKey: @"path"] parentType: [[theFolders objectAtIndex: i] objectForKey: @"type"]]; + [self _flattenFolders: o into: theTarget parent: [theFolders objectAtIndex: i] existingParent: theExistingParent]; } } @@ -811,7 +825,7 @@ void handle_eas_terminate(int signum) } allFoldersMetadata = [NSMutableArray array]; - [self _flattenFolders: [accountFolder allFoldersMetadata: SOGoMailStandardListing] into: allFoldersMetadata parent: nil parentType: nil]; + [self _flattenFolders: [accountFolder allFoldersMetadata: SOGoMailStandardListing] into: allFoldersMetadata parent: nil existingParent: nil]; // Get GUIDs of folder (IMAP) // e.g. {folderINBOX = folder6b93c528176f1151c7260000aef6df92} diff --git a/Tools/SOGoToolManageEAS.m b/Tools/SOGoToolManageEAS.m index 63fa853bd..5282e07f5 100644 --- a/Tools/SOGoToolManageEAS.m +++ b/Tools/SOGoToolManageEAS.m @@ -22,6 +22,7 @@ #import #import #import +#import #import @@ -67,7 +68,8 @@ NSURL *folderTableURL; } - (void) _setOrUnsetSyncRequest: (BOOL) set - collections: (NSArray *) collections + collections: (NSArray *) collections + context: (WOContext *) theContext { SOGoCacheGCSObject *o; NSNumber *processIdentifier; @@ -80,6 +82,7 @@ NSURL *folderTableURL; o = [SOGoCacheGCSObject objectWithName: [[[collections objectAtIndex: 0] componentsSeparatedByString: @"+"] objectAtIndex: 0] inContainer: nil useCache: NO]; [o setObjectType: ActiveSyncGlobalCacheObject]; [o setTableUrl: folderTableURL]; + [o setContext: theContext]; [o reloadIfNeeded]; if (set) @@ -319,7 +322,7 @@ NSURL *folderTableURL; } else { - [self _setOrUnsetSyncRequest: YES collections: [NSArray arrayWithObject: deviceId]]; + [self _setOrUnsetSyncRequest: YES collections: [NSArray arrayWithObject: deviceId] context: localContext]; [[oc properties] removeObjectForKey: @"SyncKey"]; [[oc properties] removeObjectForKey: @"SyncCache"]; @@ -385,7 +388,7 @@ NSURL *folderTableURL; if ([foc isNew]) continue; - [self _setOrUnsetSyncRequest: YES collections: [NSArray arrayWithObject: [cacheEntry substringFromIndex: 1]]]; + [self _setOrUnsetSyncRequest: YES collections: [NSArray arrayWithObject: [cacheEntry substringFromIndex: 1]] context: localContext]; if (![[cacheEntry substringFromIndex: 1] hasPrefix: [NSString stringWithFormat: @"%@+%@/personal", deviceId, folderType]] && [[sanitizedArguments objectAtIndex: 3] isEqualToString: @"NO"] &&