macos permission: address review comments

This commit is contained in:
Vitor Kiguchi 2022-01-10 15:30:41 +01:00
parent 7bbc94d428
commit 8b0a6b9d5e
6 changed files with 12 additions and 10 deletions

View file

@ -237,8 +237,8 @@ if (APPLE)
set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
target_sources(citra-qt PRIVATE target_sources(citra-qt PRIVATE
usage_authorization.h macos_authorization.h
usage_authorization.mm macos_authorization.mm
) )
elseif(WIN32) elseif(WIN32)
# compile as a win32 gui application instead of a console application # compile as a win32 gui application instead of a console application

View file

@ -9,7 +9,10 @@
#include <QThread> #include <QThread>
#include "citra_qt/camera/qt_multimedia_camera.h" #include "citra_qt/camera/qt_multimedia_camera.h"
#include "citra_qt/main.h" #include "citra_qt/main.h"
#include "citra_qt/usage_authorization.h"
#if defined(__APPLE__)
#include "citra_qt/macos_authorization.h"
#endif
namespace Camera { namespace Camera {
@ -189,8 +192,7 @@ void QtMultimediaCameraHandler::StopCamera() {
void QtMultimediaCameraHandler::StartCamera() { void QtMultimediaCameraHandler::StartCamera() {
#if defined(__APPLE__) #if defined(__APPLE__)
bool authorized = AppleAuthorization::CheckAuthorizationForCamera(); if (!AppleAuthorization::CheckAuthorizationForCamera()) {
if (!authorized) {
LOG_ERROR(Service_CAM, "Unable to start camera due to lack of authorization"); LOG_ERROR(Service_CAM, "Unable to start camera due to lack of authorization");
return; return;
} }

View file

@ -16,7 +16,7 @@
#include "ui_configure_audio.h" #include "ui_configure_audio.h"
#if defined(__APPLE__) #if defined(__APPLE__)
#include "citra_qt/usage_authorization.h" #include "citra_qt/macos_authorization.h"
#endif #endif
constexpr int DEFAULT_INPUT_DEVICE_INDEX = 0; constexpr int DEFAULT_INPUT_DEVICE_INDEX = 0;

View file

@ -18,7 +18,7 @@
#include "ui_configure_camera.h" #include "ui_configure_camera.h"
#if defined(__APPLE__) #if defined(__APPLE__)
#include "citra_qt/usage_authorization.h" #include "citra_qt/macos_authorization.h"
#endif #endif
const std::array<std::string, 3> ConfigureCamera::Implementations = { const std::array<std::string, 3> ConfigureCamera::Implementations = {

View file

@ -4,7 +4,7 @@
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#include "citra_qt/usage_authorization.h" #include "citra_qt/macos_authorization.h"
#include "common/logging/log.h" #include "common/logging/log.h"
namespace AppleAuthorization { namespace AppleAuthorization {
@ -33,8 +33,8 @@ void CheckAuthorization(AuthMediaType type) {
case AVAuthorizationStatusNotDetermined: { case AVAuthorizationStatusNotDetermined: {
// The app hasn't yet asked the user for camera access. // The app hasn't yet asked the user for camera access.
[AVCaptureDevice requestAccessForMediaType:media_type [AVCaptureDevice requestAccessForMediaType:media_type
completionHandler:^(BOOL) { completionHandler:^(BOOL granted) {
authorized = true; authorized = granted;
}]; }];
if (type == AuthMediaType::Camera) { if (type == AuthMediaType::Camera) {
LOG_INFO(Frontend, "Camera access requested."); LOG_INFO(Frontend, "Camera access requested.");