Add Privacy Options

This commit is contained in:
twinaphex 2014-04-06 22:59:16 +02:00
parent a802b18212
commit e779681528
10 changed files with 74 additions and 2 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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");

View File

@ -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;

View File

@ -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.

View File

@ -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");