Skip to content

Commit

Permalink
iOS: Handle new contacts permission enumerator
Browse files Browse the repository at this point in the history
iOS 18 added a new enumerator value for contact permissions,
"Limited". This value has not been added for any other permission
enumerator types such as camera. Currently we get compiler errors
for not explicitly handling this value in a switch case. This change
explicitly handles this enumerator and enables compilation.

Pick-to: 6.8 6.7 6.5
Change-Id: Idfc45902f9ae2e555fab8ba3d860a58d89651964
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
Nils Petter Skålerud committed Sep 19, 2024
1 parent 41c5856 commit 0bc5e5a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/corelib/platform/darwin/qdarwinpermissionplugin_contacts.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include <Contacts/Contacts.h>

QT_DEFINE_PERMISSION_STATUS_CONVERTER(CNAuthorizationStatus);

@interface QDarwinContactsPermissionHandler ()
@property (nonatomic, retain) CNContactStore *contactStore;
@end
Expand All @@ -21,7 +19,21 @@ @implementation QDarwinContactsPermissionHandler
- (Qt::PermissionStatus)currentStatus
{
const auto status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
return nativeStatusToQtStatus(status);
switch (status) {
case CNAuthorizationStatusAuthorized:
#if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(180000)
case CNAuthorizationStatusLimited:
#endif
return Qt::PermissionStatus::Granted;
case CNAuthorizationStatusDenied:
case CNAuthorizationStatusRestricted:
return Qt::PermissionStatus::Denied;
case CNAuthorizationStatusNotDetermined:
return Qt::PermissionStatus::Undetermined;
}
qCWarning(lcPermissions) << "Unknown permission status" << status << "detected in"
<< QT_STRINGIFY(QT_DARWIN_PERMISSION_PLUGIN);
return Qt::PermissionStatus::Denied;
}

- (QStringList)usageDescriptionsFor:(QPermission)permission
Expand Down

0 comments on commit 0bc5e5a

Please sign in to comment.