From 03e6d0012bc0d6ba4d8cb427f8d904a75d9ce036 Mon Sep 17 00:00:00 2001 From: smizrahi Date: Wed, 7 Dec 2022 17:57:00 +0100 Subject: [PATCH] fix(calendar): Fix inaccessibility to personal calendar on Mac OS X Ventura. Fixes #5639 --- SoObjects/SOGo/SOGoGCSFolder.m | 6 ++++++ SoObjects/SOGo/SOGoParentFolder.m | 13 ++++++++++++- SoObjects/SOGo/WORequest+SOGo.h | 3 ++- SoObjects/SOGo/WORequest+SOGo.m | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 2b1bf55a8..8e0ced2ee 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -431,6 +431,12 @@ static NSArray *childRecordFields = nil; cache = [SOGoCache sharedCache]; record = [[cache valueForKey: _path] objectFromJSONString]; + // FIXME: Improve MacOSX Ventura support + // Check if the problem will be fixed by Apple or if this fix should be kept in the future + // Ticket #5639 + if ([[context request] isMacOSXVenturaCalendarApp]) { + _path = [_path stringByReplacingOccurrencesOfString:@"Personal" withString:@"personal"]; + } // We check if we got a cache miss or a potentially bogus // entry from the cache diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index e39022662..a378ff027 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -221,10 +221,21 @@ static SoSecurityManager *sm = nil; while ((row = [fc fetchAttributes: attrs withZone: NULL])) { key = [row objectForKey: @"c_path4"]; + // FIXME: Improve MacOSX Ventura support + // Check if the problem will be fixed by Apple or if this fix should be kept in the future + // Ticket #5639 + if ([[context request] isMacOSXVenturaCalendarApp]) { + if ([key isEqualToString:@"personal"]) { + key = @"Personal"; + } + } + if ([key isKindOfClass: [NSString class]]) { folder = [subFolderClass objectWithName: key inContainer: self]; - [folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, key]]; + [folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, key]]; + + if (folder) [subFolders setObject: folder forKey: key]; } } diff --git a/SoObjects/SOGo/WORequest+SOGo.h b/SoObjects/SOGo/WORequest+SOGo.h index 9ae6c9104..6f9fb80f1 100644 --- a/SoObjects/SOGo/WORequest+SOGo.h +++ b/SoObjects/SOGo/WORequest+SOGo.h @@ -33,7 +33,8 @@ - (BOOL) isICal; - (BOOL) isICal4; - (BOOL) isMacOSXAddressBookApp; -- (BOOL) isIPhoneAddressBookApp; +- (BOOL)isMacOSXCalendarApp; +- (BOOL)isIPhoneAddressBookApp; - (BOOL) isAndroid; @end diff --git a/SoObjects/SOGo/WORequest+SOGo.m b/SoObjects/SOGo/WORequest+SOGo.m index 109165097..d66a95021 100644 --- a/SoObjects/SOGo/WORequest+SOGo.m +++ b/SoObjects/SOGo/WORequest+SOGo.m @@ -242,5 +242,21 @@ return ([[cc userAgent] rangeOfString: @"Android"].location != NSNotFound); } +- (BOOL) isMacOSXVenturaCalendarApp +{ + WEClientCapabilities *cc; + BOOL b; + + cc = [self clientCapabilities]; + + b = ( + ( + [[cc userAgent] rangeOfString: @"macOS/13"].location != NSNotFound + && [[cc userAgent] rangeOfString: @"dataaccessd"].location != NSNotFound + ) + ); + + return b; +} @end