From e7796815280047fed9d1058eaafb3f4d2fefc72b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 6 Apr 2014 22:59:16 +0200 Subject: [PATCH] Add Privacy Options --- driver.c | 4 ++-- frontend/menu/disp/rgui.c | 2 ++ frontend/menu/disp/rmenu.c | 2 ++ frontend/menu/disp/rmenu_xui.cpp | 2 ++ frontend/menu/menu_common.c | 11 +++++++++++ frontend/menu/menu_common.h | 4 ++++ frontend/menu/menu_settings.c | 28 ++++++++++++++++++++++++++++ general.h | 2 ++ retroarch.cfg | 8 ++++++++ settings.c | 13 +++++++++++++ 10 files changed, 74 insertions(+), 2 deletions(-) diff --git a/driver.c b/driver.c index 748bff2159..7140243b6b 100644 --- a/driver.c +++ b/driver.c @@ -615,7 +615,7 @@ float driver_sensor_get_input(unsigned port, unsigned id) #ifdef HAVE_CAMERA bool driver_camera_start(void) { - if (driver.camera && driver.camera_data) + if (driver.camera && driver.camera_data && g_settings.camera.allow) return driver.camera->start(driver.camera_data); else return false; @@ -641,7 +641,7 @@ void driver_camera_poll(void) #ifdef HAVE_LOCATION bool driver_location_start(void) { - if (driver.location && driver.location_data) + if (driver.location && driver.location_data && g_settings.location.allow) return driver.location->start(driver.location_data); else return false; diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index 3ff18354c5..0f7954d8cd 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -321,6 +321,8 @@ static void rgui_render(void *data) strlcpy(title, "CORE OPTIONS", sizeof(title)); else if (menu_type == RGUI_SETTINGS_CORE_INFO) strlcpy(title, "CORE INFO", sizeof(title)); + else if (menu_type == RGUI_SETTINGS_PRIVACY_OPTIONS) + strlcpy(title, "PRIVACY OPTIONS", sizeof(title)); #ifdef HAVE_SHADER_MANAGER else if (menu_type_is(menu_type) == RGUI_SETTINGS_SHADER_OPTIONS) snprintf(title, sizeof(title), "SHADER %s", dir); diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index feb43ad55c..dd1aed5cac 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -180,6 +180,8 @@ static void rmenu_render(void *data) strlcpy(title, "CORE OPTIONS", sizeof(title)); else if (menu_type == RGUI_SETTINGS_CORE_INFO) strlcpy(title, "CORE INFO", sizeof(title)); + else if (menu_type == RGUI_SETTINGS_PRIVACY_OPTIONS) + strlcpy(title, "PRIVACY OPTIONS", sizeof(title)); #ifdef HAVE_SHADER_MANAGER else if (menu_type_is(menu_type) == RGUI_SETTINGS_SHADER_OPTIONS) snprintf(title, sizeof(title), "SHADER %s", dir); diff --git a/frontend/menu/disp/rmenu_xui.cpp b/frontend/menu/disp/rmenu_xui.cpp index 415998ea8e..ea5504a627 100644 --- a/frontend/menu/disp/rmenu_xui.cpp +++ b/frontend/menu/disp/rmenu_xui.cpp @@ -433,6 +433,8 @@ static void rmenu_xui_render(void *data) strlcpy(title, "CORE OPTIONS", sizeof(title)); else if (menu_type == RGUI_SETTINGS_CORE_INFO) strlcpy(title, "CORE INFO", sizeof(title)); + else if (menu_type == RGUI_SETTINGS_PRIVACY_OPTIONS) + strlcpy(title, "PRIVACY OPTIONS", sizeof(title)); #ifdef HAVE_SHADER_MANAGER else if (menu_type_is(menu_type) == RGUI_SETTINGS_SHADER_OPTIONS) snprintf(title, sizeof(title), "SHADER %s", dir); diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index e7acf6de54..aed93cf33d 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -969,6 +969,7 @@ static int menu_settings_iterate(void *data, unsigned action) || menu_type == RGUI_SETTINGS_CORE_OPTIONS || menu_type == RGUI_SETTINGS_AUDIO_OPTIONS || menu_type == RGUI_SETTINGS_DISK_OPTIONS + || menu_type == RGUI_SETTINGS_PRIVACY_OPTIONS || menu_type == RGUI_SETTINGS_GENERAL_OPTIONS || menu_type == RGUI_SETTINGS_VIDEO_OPTIONS || menu_type == RGUI_SETTINGS_SHADER_OPTIONS @@ -2005,6 +2006,16 @@ void menu_populate_entries(void *data, unsigned menu_type) if (g_extern.system.disk_control.get_num_images) file_list_push(rgui->selection_buf, "Disk Options", RGUI_SETTINGS_DISK_OPTIONS, 0); } + file_list_push(rgui->selection_buf, "Privacy Options", RGUI_SETTINGS_PRIVACY_OPTIONS, 0); + break; + case RGUI_SETTINGS_PRIVACY_OPTIONS: + file_list_clear(rgui->selection_buf); +#ifdef HAVE_CAMERA + file_list_push(rgui->selection_buf, "Allow Camera", RGUI_SETTINGS_PRIVACY_CAMERA_ALLOW, 0); +#endif +#ifdef HAVE_LOCATION + file_list_push(rgui->selection_buf, "Allow Location Services", RGUI_SETTINGS_PRIVACY_LOCATION_ALLOW, 0); +#endif break; case RGUI_SETTINGS_DISK_OPTIONS: file_list_clear(rgui->selection_buf); diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 9daee47d9a..72aea820b6 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -115,6 +115,7 @@ typedef enum RGUI_SETTINGS_PATH_OPTIONS, RGUI_SETTINGS_OVERLAY_OPTIONS, RGUI_SETTINGS_NETPLAY_OPTIONS, + RGUI_SETTINGS_PRIVACY_OPTIONS, RGUI_SETTINGS_OPTIONS, RGUI_SETTINGS_DRIVERS, RGUI_SETTINGS_REWIND_ENABLE, @@ -172,6 +173,9 @@ typedef enum RGUI_SETTINGS_NETPLAY_DELAY_FRAMES, RGUI_SETTINGS_NETPLAY_NICKNAME, + RGUI_SETTINGS_PRIVACY_CAMERA_ALLOW, + RGUI_SETTINGS_PRIVACY_LOCATION_ALLOW, + RGUI_SETTINGS_OVERLAY_PRESET, RGUI_SETTINGS_OVERLAY_OPACITY, RGUI_SETTINGS_OVERLAY_SCALE, diff --git a/frontend/menu/menu_settings.c b/frontend/menu/menu_settings.c index 67f36d2930..6f4f047f8b 100644 --- a/frontend/menu/menu_settings.c +++ b/frontend/menu/menu_settings.c @@ -99,6 +99,7 @@ unsigned menu_type_is(unsigned type) type == RGUI_SETTINGS_AUDIO_OPTIONS || type == RGUI_SETTINGS_DISK_OPTIONS || type == RGUI_SETTINGS_PATH_OPTIONS || + type == RGUI_SETTINGS_PRIVACY_OPTIONS || type == RGUI_SETTINGS_OVERLAY_OPTIONS || type == RGUI_SETTINGS_NETPLAY_OPTIONS || type == RGUI_SETTINGS_OPTIONS || @@ -1858,6 +1859,22 @@ int menu_set_settings(void *data, unsigned setting, unsigned action) else if (action == RGUI_ACTION_START) g_settings.osk.enable = false; break; +#endif +#ifdef HAVE_CAMERA + case RGUI_SETTINGS_PRIVACY_CAMERA_ALLOW: + if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT) + g_settings.camera.allow = !g_settings.camera.allow; + else if (action == RGUI_ACTION_START) + g_settings.camera.allow = false; + break; +#endif +#ifdef HAVE_LOCATION + case RGUI_SETTINGS_PRIVACY_LOCATION_ALLOW: + if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT) + g_setttings.location.allow = !g_settings.location.allow; + else if (action == RGUI_ACTION_START) + g_settings.location.allow = false; + break; #endif default: break; @@ -2115,6 +2132,7 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w, case RGUI_SETTINGS_PATH_OPTIONS: case RGUI_SETTINGS_OVERLAY_OPTIONS: case RGUI_SETTINGS_NETPLAY_OPTIONS: + case RGUI_SETTINGS_PRIVACY_OPTIONS: case RGUI_SETTINGS_OPTIONS: case RGUI_SETTINGS_DRIVERS: case RGUI_SETTINGS_CUSTOM_BIND_ALL: @@ -2291,6 +2309,16 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w, snprintf(type_str, type_str_size, g_extern.netplay_is_spectate ? "ON" : "OFF"); break; #endif +#ifdef HAVE_CAMERA + case RGUI_SETTINGS_PRIVACY_CAMERA_ALLOW: + snprintf(type_str, type_str_size, g_settings.camera.allow ? "ON" : "OFF"); + break; +#endif +#ifdef HAVE_LOCATION + case RGUI_SETTINGS_PRIVACY_LOCATION_ALLOW: + snprintf(type_str, type_str_size, g_settings.location.allow ? "ON" : "OFF"); + break; +#endif #ifdef HAVE_OSK case RGUI_SETTINGS_ONSCREEN_KEYBOARD_ENABLE: snprintf(type_str, type_str_size, g_settings.osk.enable ? "ON" : "OFF"); diff --git a/general.h b/general.h index 31f2575dd2..389d344550 100644 --- a/general.h +++ b/general.h @@ -192,6 +192,7 @@ struct settings { char driver[32]; char device[PATH_MAX]; + bool allow; unsigned width; unsigned height; } camera; @@ -201,6 +202,7 @@ struct settings struct { char driver[32]; + bool allow; int update_interval_ms; int update_interval_distance; } location; diff --git a/retroarch.cfg b/retroarch.cfg index 25ed6e8ee0..4dcb487e9e 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -496,6 +496,14 @@ # Override the default camera device the camera driver uses. This is driver dependant. # camera_device = +# Override the default privacy permission for cores that want to access camera services. Is "false" by default. +# camera_allow = false + +#### Location + +# Override the default privacy permission for cores that want to access location services. Is "false" by default. +# location_allow = false + #### Misc # Enable rewinding. This will take a performance hit when playing, so it is disabled by default. diff --git a/settings.c b/settings.c index bc29c3e63c..6eb522f444 100644 --- a/settings.c +++ b/settings.c @@ -313,6 +313,14 @@ void config_set_defaults(void) g_settings.rgui_show_start_screen = rgui_show_start_screen; #endif +#ifdef HAVE_LOCATION + g_settings.location.allow = false; +#endif + +#ifdef HAVE_CAMERA + g_settings.camera.allow = false; +#endif + rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1)); rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest)); memcpy(g_settings.input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1)); @@ -900,6 +908,11 @@ bool config_load_file(const char *path, bool set_defaults) #ifdef HAVE_CAMERA CONFIG_GET_STRING(camera.device, "camera_device"); + CONFIG_GET_BOOL(camera.allow, "camera_allow"); +#endif + +#ifdef HAVE_LOCATION + CONFIG_GET_BOOL(location.allow, "location_allow"); #endif CONFIG_GET_STRING(video.driver, "video_driver");