From 2736e908e9da05ed8a03a8f163237ec68606e1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 27 Jun 2023 17:55:24 +0200 Subject: [PATCH] permissions: Handle EKAuthorizationStatusWriteOnly on macOS 14/iOS 17 For now we do not have a QCalendarPermission::AccessMode::WriteOnly, so we have to report Qt::PermissionStatus::Denied. Fixes: QTBUG-114864 Pick-to: 6.5 6.6 Change-Id: I94e92912ef4c24adb524ccf2cf28553115d6781b Reviewed-by: Volker Hilsheimer Reviewed-by: Doris Verria --- .../qdarwinpermissionplugin_calendar.mm | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/corelib/platform/darwin/qdarwinpermissionplugin_calendar.mm b/src/corelib/platform/darwin/qdarwinpermissionplugin_calendar.mm index 79a85ef3d2..cf91a4f1cd 100644 --- a/src/corelib/platform/darwin/qdarwinpermissionplugin_calendar.mm +++ b/src/corelib/platform/darwin/qdarwinpermissionplugin_calendar.mm @@ -5,8 +5,6 @@ #include -QT_DEFINE_PERMISSION_STATUS_CONVERTER(EKAuthorizationStatus); - @interface QDarwinCalendarPermissionHandler () @property (nonatomic, retain) EKEventStore *eventStore; @end @@ -20,8 +18,22 @@ QT_DEFINE_PERMISSION_STATUS_CONVERTER(EKAuthorizationStatus); - (Qt::PermissionStatus)currentStatus { - const auto status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent]; - return nativeStatusToQtStatus(status); + switch ([EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent]) { + case EKAuthorizationStatusNotDetermined: + return Qt::PermissionStatus::Undetermined; + case EKAuthorizationStatusRestricted: + case EKAuthorizationStatusDenied: + return Qt::PermissionStatus::Denied; + case EKAuthorizationStatusAuthorized: + return Qt::PermissionStatus::Granted; +#if QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(140000, 170000) + case EKAuthorizationStatusWriteOnly: + // FIXME: Add WriteOnly AccessMode + return Qt::PermissionStatus::Denied; +#endif + } + + Q_UNREACHABLE(); } - (QStringList)usageDescriptionsFor:(QPermission)permission