(feat) now possible to choose which folders to sync over EAS

pull/110/head
Ludovic Marcotte 2015-10-20 15:33:18 -04:00
parent 114622fee0
commit 2ee09159a2
2 changed files with 33 additions and 30 deletions

View File

@ -707,22 +707,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- (void) processFolderSync: (id <DOMElement>) theDocumentElement - (void) processFolderSync: (id <DOMElement>) theDocumentElement
inResponse: (WOResponse *) theResponse inResponse: (WOResponse *) theResponse
{ {
NSString *key, *cKey, *nkey, *name, *serverId, *parentId, *nameInCache, *personalFolderName, *syncKey, *folderType; NSString *key, *cKey, *nkey, *name, *serverId, *parentId, *nameInCache, *personalFolderName, *syncKey, *folderType, *operation;
NSMutableDictionary *cachedGUIDs, *metadata;
NSMutableArray *folders, *processedFolders;
NSDictionary *folderMetadata, *imapGUIDs; NSDictionary *folderMetadata, *imapGUIDs;
NSArray *allFoldersMetadata, *allKeys; NSArray *allFoldersMetadata, *allKeys;
NSMutableDictionary *cachedGUIDs, *metadata;
SOGoMailAccounts *accountsFolder; SOGoMailAccounts *accountsFolder;
SOGoMailAccount *accountFolder; SOGoMailAccount *accountFolder;
NSMutableString *s, *commands; NSMutableString *s, *commands;
SOGoUserFolder *userFolder; SOGoUserFolder *userFolder;
NSMutableArray *folders, *processedFolders;
SoSecurityManager *sm; SoSecurityManager *sm;
SOGoCacheGCSObject *o; SOGoCacheGCSObject *o;
id currentFolder; id currentFolder;
NSData *d; NSData *d;
int status, command_count, i, type, fi, count; int status, command_count, i, type, fi, count;
BOOL first_sync; BOOL first_sync;
sm = [SoSecurityManager sharedSecurityManager]; sm = [SoSecurityManager sharedSecurityManager];
@ -840,32 +839,33 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
else else
{ {
if ([cKey rangeOfString: @"vevent" options: NSCaseInsensitiveSearch].location != NSNotFound || if ([cKey rangeOfString: @"vevent" options: NSCaseInsensitiveSearch].location != NSNotFound ||
[cKey rangeOfString: @"vtodo" options: NSCaseInsensitiveSearch].location != NSNotFound) [cKey rangeOfString: @"vtodo" options: NSCaseInsensitiveSearch].location != NSNotFound)
folderType = @"Calendar"; folderType = @"Calendar";
else else
folderType = @"Contacts"; folderType = @"Contacts";
if ([ cKey rangeOfString: @"/"].location != NSNotFound) if ([ cKey rangeOfString: @"/"].location != NSNotFound)
currentFolder = [[[[context activeUser] homeFolderInContext: context] lookupName: folderType inContext: context acquire: NO] currentFolder = [[[[context activeUser] homeFolderInContext: context] lookupName: folderType inContext: context acquire: NO]
lookupName: [cKey substringFromIndex: [cKey rangeOfString: @"/"].location+1] inContext: context acquire: NO]; lookupName: [cKey substringFromIndex: [cKey rangeOfString: @"/"].location+1] inContext: context acquire: NO];
// remove the folder from device if it doesn't exists or it has not the proper permissions // Remove the folder from device if it doesn't exist, we don't want to sync it, or it doesn't have the proper permissions
if (!currentFolder || if (!currentFolder ||
[sm validatePermission: SoPerm_DeleteObjects ![currentFolder synchronize] ||
onObject: currentFolder [sm validatePermission: SoPerm_DeleteObjects
inContext: context] || onObject: currentFolder
[sm validatePermission: SoPerm_AddDocumentsImagesAndFiles inContext: context] ||
onObject: currentFolder [sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
inContext: context]) onObject: currentFolder
{ inContext: context])
[commands appendFormat: @"<Delete><ServerId>%@</ServerId></Delete>", [cKey stringByEscapingURL] ]; {
command_count++; [commands appendFormat: @"<Delete><ServerId>%@</ServerId></Delete>", [cKey stringByEscapingURL] ];
[o destroy]; command_count++;
} [o destroy];
} }
} }
} }
}
// Handle addition and changes // Handle addition and changes
for (i = 0; i < [allFoldersMetadata count]; i++) for (i = 0; i < [allFoldersMetadata count]; i++)
@ -965,11 +965,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
folders = [[[[[context activeUser] homeFolderInContext: context] lookupName: @"Calendar" inContext: context acquire: NO] subFolders] mutableCopy]; folders = [[[[[context activeUser] homeFolderInContext: context] lookupName: @"Calendar" inContext: context acquire: NO] subFolders] mutableCopy];
[folders addObjectsFromArray: [[[[context activeUser] homeFolderInContext: context] lookupName: @"Contacts" inContext: context acquire: NO] subFolders]]; [folders addObjectsFromArray: [[[[context activeUser] homeFolderInContext: context] lookupName: @"Contacts" inContext: context acquire: NO] subFolders]];
// Inside this loop we remove all the folder without write/delete permissions // We remove all the folders that aren't GCS-ones, that we don't want to synchronize and
// the ones without write/delete permissions
count = [folders count]-1; count = [folders count]-1;
for (; count >= 0; count--) for (; count >= 0; count--)
{ {
if ([sm validatePermission: SoPerm_DeleteObjects if (![[folders objectAtIndex: count] isKindOfClass: [SOGoGCSFolder class]] ||
![[folders objectAtIndex: count] synchronize] ||
[sm validatePermission: SoPerm_DeleteObjects
onObject: [folders objectAtIndex: count] onObject: [folders objectAtIndex: count]
inContext: context] || inContext: context] ||
[sm validatePermission: SoPerm_AddDocumentsImagesAndFiles [sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
@ -981,7 +984,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
count = [folders count]-1; count = [folders count]-1;
NSString *operation;
for (fi = 0; fi <= count ; fi++) for (fi = 0; fi <= count ; fi++)
{ {

1
NEWS
View File

@ -3,6 +3,7 @@
New features New features
- initial S/MIME support for EAS (#3327) - initial S/MIME support for EAS (#3327)
- now possible to choose which folders to sync over EAS
Enhancements Enhancements
- we no longer always entirely rewrite messages for Outlook 2013 when using EAS - we no longer always entirely rewrite messages for Outlook 2013 when using EAS