From 063fb2be3d39c7e12d3bd260f0116707efbb559d Mon Sep 17 00:00:00 2001 From: leecher1337 Date: Wed, 11 Oct 2023 21:02:24 +0200 Subject: [PATCH 1/3] Fix for excessive memory usage on mailboxes with thousands of folders --- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 48da086be..57fae8b10 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -2627,17 +2627,17 @@ FIXME // We first check of any of the collections we want to sync are already // in an other sync process. If that's the case, we do not do anything // and we return immediately. So we'll let the other sync process terminate + globalMetadata = [self globalMetadataForDevice]; for (j = 0; j < [allCollections count]; j++) { aCollection = [allCollections objectAtIndex: j]; - globalMetadata = [self globalMetadataForDevice]; key = [NSString stringWithFormat: @"SyncRequest+%@", [[[(id)[aCollection getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]]; if (!([[globalMetadata objectForKey: key] isEqual: processIdentifier])) { if (debugOn) - [self logWithFormat: @"EAS - Discard response %@", [self globalMetadataForDevice]]; + [self logWithFormat: @"EAS - Discard response %@", globalMetadata]; [output appendString: @"13"]; [output appendString: @""]; From 4b45dc7584984602071efe99b9638c6231efba8c Mon Sep 17 00:00:00 2001 From: Hivert Quentin Date: Tue, 17 Oct 2023 09:23:33 +0200 Subject: [PATCH 2/3] fix(translation): incorret value causing trouble to transifex --- UI/PreferencesUI/English.lproj/Localizable.strings | 2 +- UI/PreferencesUI/French.lproj/Localizable.strings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index 6db3ecc84..8d511c694 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -507,7 +507,7 @@ "Let SOGo handle everything" = "Let SOGo handle everything"; /* Password Recovery */ -"Password recovery mode" = "Password recovery"; +"Password recovery mode" = "Password recovery mode"; "Question" = "Question"; "Secondary e-mail" = "Secondary e-mail"; "Answer" = "Answer"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 7ca7c3a23..6baef93f4 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -507,7 +507,7 @@ "Let SOGo handle everything" = "Laissez SOGo s'occuper de tout"; /* Password Recovery */ -"Password recovery mode" = "Récupération de mot de passe"; +"Password recovery mode" = "Mode de récupération de mot de passe"; "Question" = "Question"; "Secondary e-mail" = "E-mail secondaire"; "Answer" = "Réponse"; From 65f8336255577566282039f4058fe4f3c38a16d4 Mon Sep 17 00:00:00 2001 From: smizrahi Date: Wed, 18 Oct 2023 11:43:11 +0200 Subject: [PATCH 3/3] feat(core): Add mobile provisioning download for Apple's devices. Fix shared calendar and contacts --- SoObjects/SOGo/SOGoMobileProvision.h | 4 +-- SoObjects/SOGo/SOGoMobileProvision.m | 21 ++++++++------- SoObjects/SOGo/SOGoObject.h | 3 ++- SoObjects/SOGo/SOGoObject.m | 5 ++++ UI/Contacts/UIxContactFolderActions.m | 26 +++++++++++++++++++ UI/Contacts/UIxContactView.m | 26 ------------------- UI/Contacts/product.plist | 10 +++---- UI/Scheduler/UIxCalView.m | 2 +- .../ContactsUI/UIxContactFoldersView.wox | 6 +++++ .../js/Contacts/AddressBook.service.js | 15 +++++++++-- .../js/Scheduler/Calendar.service.js | 15 +++++++++-- 11 files changed, 84 insertions(+), 49 deletions(-) diff --git a/SoObjects/SOGo/SOGoMobileProvision.h b/SoObjects/SOGo/SOGoMobileProvision.h index b6b4acafd..7dbe31bdc 100644 --- a/SoObjects/SOGo/SOGoMobileProvision.h +++ b/SoObjects/SOGo/SOGoMobileProvision.h @@ -37,8 +37,8 @@ typedef enum } -+ (NSString *)plistForCalendarsWithContext:(WOContext *)context andPath:(NSString *)path; -+ (NSString *)plistForContactsWithContext:(WOContext *)context andPath:(NSString *)path; ++ (NSString *)plistForCalendarsWithContext:(WOContext *)context andPath:(NSString *)path andName:(NSString *)name; ++ (NSString *)plistForContactsWithContext:(WOContext *)context andPath:(NSString *)path andName:(NSString *)name; @end diff --git a/SoObjects/SOGo/SOGoMobileProvision.m b/SoObjects/SOGo/SOGoMobileProvision.m index c580c8715..f18577c04 100644 --- a/SoObjects/SOGo/SOGoMobileProvision.m +++ b/SoObjects/SOGo/SOGoMobileProvision.m @@ -23,10 +23,11 @@ #import "SOGoMobileProvision.h" #import "SOGoUser.h" +#import "NSString+Crypto.h" @implementation SOGoMobileProvision -+ (NSString *)_plistWithContext:(WOContext *)context andPath:(NSString *)path andType:(ProvisioningType) provisioningType ++ (NSString *)_plistWithContext:(WOContext *)context andPath:(NSString *)path andType:(ProvisioningType) provisioningType andName:(NSString *)name { NSData *plistData; SOGoUser *activeUser; @@ -58,23 +59,23 @@ provisioning = [NSDictionary dictionaryWithObjectsAndKeys: [NSArray arrayWithObject: [NSDictionary dictionaryWithObjectsAndKeys: - [NSString stringWithFormat:@"%@ %@", type, [activeUser login]], [NSString stringWithFormat:@"%@%@", prefix, @"AccountDescription"], + [NSString stringWithFormat:@"%@ %@", type, name], [NSString stringWithFormat:@"%@%@", prefix, @"AccountDescription"], [serverURL host], [NSString stringWithFormat:@"%@%@", prefix, @"HostName"], [serverURL port], [NSString stringWithFormat:@"%@%@", prefix, @"Port"], path, [NSString stringWithFormat:@"%@%@", prefix, @"PrincipalURL"], [NSNumber numberWithBool:[[serverURL scheme] isEqualToString:@"https"]], [NSString stringWithFormat:@"%@%@", prefix, @"UseSSL"], [activeUser login], [NSString stringWithFormat:@"%@%@", prefix, @"Username"], [NSString stringWithFormat: @"SOGo %@ provisioning", prefix], @"PayloadDescription", - [NSString stringWithFormat:@"%@ %@", type, [activeUser login]], @"PayloadDisplayName", - [NSString stringWithFormat:@"%@.apple.%@", [serverURL host], [prefix lowercaseString]], @"PayloadIdentifier", + [NSString stringWithFormat:@"%@ %@", type, name], @"PayloadDisplayName", + [NSString stringWithFormat:@"%@.%@.apple.%@", [serverURL host], [name asMD5String], [prefix lowercaseString]], @"PayloadIdentifier", [serverURL host], @"PayloadOrganization", payloadType, @"PayloadType", [SOGoObject globallyUniqueObjectId], @"PayloadUUID", [NSNumber numberWithInt: 1], @"PayloadVersion", nil]], @"PayloadContent", [NSString stringWithFormat:@"SOGo %@ provisioning", prefix], @"PayloadDescription", - [NSString stringWithFormat: @"%@ (%@)", [activeUser login], type], @"PayloadDisplayName", - [NSString stringWithFormat:@"%@.%@.apple", [prefix lowercaseString], [serverURL host]], @"PayloadIdentifier", + [NSString stringWithFormat: @"%@ (%@)", name, type], @"PayloadDisplayName", + [NSString stringWithFormat:@"%@.%@.%@.apple", [prefix lowercaseString], [serverURL host], [name asMD5String]], @"PayloadIdentifier", @"SOGo", @"PayloadOrganization", [NSNumber numberWithBool: NO], @"PayloadRemovalDisallowed", @"Configuration", @"PayloadType", @@ -88,12 +89,12 @@ error: &error]; } -+ (NSString *)plistForCalendarsWithContext:(WOContext *)context andPath:(NSString *)path ++ (NSString *)plistForCalendarsWithContext:(WOContext *)context andPath:(NSString *)path andName:(NSString *)name { NSData *plistData; SOGoUser *activeUser; - plistData = [self _plistWithContext: context andPath: path andType: ProvisioningTypeCalendar]; + plistData = [self _plistWithContext: context andPath: path andType: ProvisioningTypeCalendar andName: name]; if (nil != plistData) { return [[[NSString alloc] initWithData:plistData encoding:NSUTF8StringEncoding] autorelease]; } else { @@ -102,12 +103,12 @@ } } -+ (NSString *)plistForContactsWithContext:(WOContext *)context andPath:(NSString *)path ++ (NSString *)plistForContactsWithContext:(WOContext *)context andPath:(NSString *)path andName:(NSString *)name { NSData *plistData; SOGoUser *activeUser; - plistData = [self _plistWithContext: context andPath: path andType: ProvisioningTypeContact]; + plistData = [self _plistWithContext: context andPath: path andType: ProvisioningTypeContact andName: name]; if (nil != plistData) { return [[[NSString alloc] initWithData:plistData encoding:NSUTF8StringEncoding] autorelease]; } else { diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index c493e3caf..f0633e56b 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -103,7 +103,8 @@ /* ownership */ -- (void) setOwner: (NSString *) newOwner; +- (NSString *)owner; +- (void)setOwner:(NSString *)newOwner; - (NSString *) ownerInContext: (id) _ctx; /* a helper that determines whether access rights can be ignored on diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 1ea37ee78..e1187518b 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -211,6 +211,11 @@ /* ownership */ +- (NSString *) owner +{ + return owner; +} + - (void) setOwner: (NSString *) newOwner { NSString *uid; diff --git a/UI/Contacts/UIxContactFolderActions.m b/UI/Contacts/UIxContactFolderActions.m index 1ace283af..f3e99f667 100644 --- a/UI/Contacts/UIxContactFolderActions.m +++ b/UI/Contacts/UIxContactFolderActions.m @@ -51,6 +51,7 @@ #import #import +#import #import "UIxContactFolderActions.h" @@ -463,4 +464,29 @@ static NSArray *photoTags = nil; return rc; } +- (WOResponse *) mobileconfigAction +{ + SOGoContactGCSFolder *folder; + NSString *davURL, *plistContent, *disposition; + WOResponse *response; + + folder = [self clientObject]; + davURL = [folder davURLAsString]; + plistContent = [SOGoMobileProvision plistForContactsWithContext: context andPath: davURL andName: [NSString stringWithFormat: @"%@ - %@", [folder owner], [folder realNameInContainer]]]; + + if (nil != plistContent) { + response = [self responseWithStatus: 200 + andString: plistContent]; + [response setHeader: @"application/x-plist; charset=utf-8" + forKey: @"content-type"]; + disposition = [NSString stringWithString: @"attachment; filename=\"contacts.mobileconfig\""]; + [response setHeader: disposition forKey: @"Content-Disposition"]; + } else { + response = [self responseWithStatus: 500 + andString: @"Error while generating profile"]; + } + + return response; +} + @end /* UIxContactFolderActions */ diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index f4e6408c8..cec10d864 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -35,7 +35,6 @@ #import #import #import -#import #import #import @@ -450,29 +449,4 @@ return [NSString stringWithFormat: @"%@/photo", [soURL absoluteString]]; } -- (WOResponse *) mobileconfigAction -{ - SOGoContactFolders *folders; - NSString *davURL, *plistContent, *disposition; - WOResponse *response; - - folders = [self clientObject]; - davURL = [[folders container] davURLAsString]; - plistContent = [SOGoMobileProvision plistForContactsWithContext: context andPath: davURL]; - - if (nil != plistContent) { - response = [self responseWithStatus: 200 - andString: plistContent]; - [response setHeader: @"application/x-plist; charset=utf-8" - forKey: @"content-type"]; - disposition = [NSString stringWithString: @"attachment; filename=\"contacts.mobileconfig\""]; - [response setHeader: disposition forKey: @"Content-Disposition"]; - } else { - response = [self responseWithStatus: 500 - andString: @"Error while generating profile"]; - } - - return response; -} - @end /* UIxContactView */ diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index 4406e6fa2..84d1d2c4b 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -50,11 +50,6 @@ pageName = "UIxContactFoldersView"; actionName = "saveDragHandleState"; }; - mobileconfig = { - protectedBy = "Access Contents Information"; - actionClass = "UIxContactView"; - actionName = "mobileconfig"; - }; }; }; @@ -115,6 +110,11 @@ pageName = "UIxContactFolderProperties"; actionName = "saveProperties"; }; + mobileconfig = { + protectedBy = "Access Contents Information"; + actionClass = "UIxContactFolderActions"; + actionName = "mobileconfig"; + }; }; }; diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index a52b2f55a..96090eabe 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -666,7 +666,7 @@ folders = [self clientObject]; davURL = [[folders container] davURLAsString]; - plistContent = [SOGoMobileProvision plistForCalendarsWithContext: context andPath: davURL]; + plistContent = [SOGoMobileProvision plistForCalendarsWithContext: context andPath: davURL andName: [folders owner]]; if (nil != plistContent) { response = [self responseWithStatus: 200 diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index b280a1e8e..c9cace019 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -205,6 +205,12 @@ + + + +  + + diff --git a/UI/WebServerResources/js/Contacts/AddressBook.service.js b/UI/WebServerResources/js/Contacts/AddressBook.service.js index 832bf1d76..06f3d412f 100644 --- a/UI/WebServerResources/js/Contacts/AddressBook.service.js +++ b/UI/WebServerResources/js/Contacts/AddressBook.service.js @@ -756,14 +756,25 @@ * @returns a promise of the HTTP operation */ AddressBook.prototype.downloadProvisioningProfile = function () { - var options; + var options, resource, index, ownerPaths, realOwnerId, path; options = { type: 'application/octet-stream', filename: 'addressbook.mobileconfig' } - return AddressBook.$$resource.open('', 'mobileconfig', null, options); + if (this.isSubscription) { + index = this.urls.cardDavURL.indexOf('/dav/'); + ownerPaths = this.urls.cardDavURL.substring(index + 5).split(/\//); + realOwnerId = ownerPaths[0]; + resource = AddressBook.$$resource.userResource(realOwnerId); + path = ownerPaths[1] + '/' + ownerPaths[2]; + } else { + resource = AddressBook.$$resource; + path = this.id; + } + + return resource.open(path, 'mobileconfig', null, options); }; /** diff --git a/UI/WebServerResources/js/Scheduler/Calendar.service.js b/UI/WebServerResources/js/Scheduler/Calendar.service.js index cf30e3f89..577c16317 100644 --- a/UI/WebServerResources/js/Scheduler/Calendar.service.js +++ b/UI/WebServerResources/js/Scheduler/Calendar.service.js @@ -583,14 +583,25 @@ * @returns a promise of the HTTP operation */ Calendar.prototype.downloadProvisioningProfile = function () { - var options; + var options, resource, index, ownerPaths, realOwnerId, path; options = { type: 'application/octet-stream', filename: 'calendar.mobileconfig' } - return Calendar.$$resource.open('', 'mobileconfig', null, options); + if (this.isSubscription) { + index = this.urls.webDavICSURL.indexOf('/dav/'); + ownerPaths = this.urls.webDavICSURL.substring(index + 5).split(/\//); + realOwnerId = ownerPaths[0]; + resource = Calendar.$$resource.userResource(realOwnerId); + path = 'Calendar'; + } else { + resource = Calendar.$$resource; + path = ''; + } + + return resource.open(path, 'mobileconfig', null, options); }; /**