From 24af521bf1236b72f4dd0b398cd5acf324e17c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 22 Mar 2016 05:46:36 +0700 Subject: [PATCH] (Menu) Add a first Lakka Service setting: SSH Enable --- configuration.c | 16 ++++++++++++++++ configuration.h | 5 +++++ lakka.h | 22 ++++++++++++++++++++++ menu/intl/menu_hash_us.c | 4 ++++ menu/menu_hash.h | 2 ++ menu/menu_setting.c | 27 +++++++++++++++++++++++---- 6 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 lakka.h diff --git a/configuration.c b/configuration.c index 66982a89e4..1c9a2683bb 100644 --- a/configuration.c +++ b/configuration.c @@ -35,6 +35,7 @@ #include "retroarch.h" #include "system.h" #include "verbosity.h" +#include "lakka.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -599,6 +600,10 @@ static void config_set_defaults(void) settings->content_history_size = default_content_history_size; settings->libretro_log_level = libretro_log_level; +#ifdef HAVE_LAKKA + settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH); +#endif + #ifdef HAVE_MENU if (first_initialized) settings->menu_show_start_screen = default_menu_show_start_screen; @@ -1724,6 +1729,10 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, settings, stdin_cmd_enable, "stdin_cmd_enable"); #endif +#ifdef HAVE_LAKKA + settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH); +#endif + #ifdef HAVE_NETWORK_GAMEPAD CONFIG_GET_BOOL_BASE(conf, settings, network_remote_enable, "network_remote_enable"); for (i = 0; i < MAX_USERS; i++) @@ -2844,6 +2853,13 @@ bool config_save_file(const char *path) settings->network_cmd_port); #endif +#ifdef HAVE_LAKKA + if (settings->ssh_enable) + fopen(LAKKA_SSH_PATH, "ab+"); + else + remove(LAKKA_SSH_PATH); +#endif + config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio); config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio); diff --git a/configuration.h b/configuration.h index 6f2346f8bc..d519e50ef3 100644 --- a/configuration.h +++ b/configuration.h @@ -399,6 +399,11 @@ typedef struct settings unsigned int user_language; bool config_save_on_exit; + +#ifdef HAVE_LAKKA + bool ssh_enable; +#endif + } settings_t; /** diff --git a/lakka.h b/lakka.h new file mode 100644 index 0000000000..926087516f --- /dev/null +++ b/lakka.h @@ -0,0 +1,22 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __RARCH_LAKKA_H +#define __RARCH_LAKKA_H + +#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf" + +#endif diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 80e199366c..b4dbf4e0cd 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -262,6 +262,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) return "netplay_tcp_udp_port"; case MENU_LABEL_NETPLAY_ENABLE: return "netplay_enable"; + case MENU_LABEL_SSH_ENABLE: + return "ssh_enable"; case MENU_LABEL_NETPLAY_DELAY_FRAMES: return "netplay_delay_frames"; case MENU_LABEL_NETPLAY_MODE: @@ -1008,6 +1010,8 @@ const char *menu_hash_to_str_us(uint32_t hash) return "Netplay TCP/UDP Port"; case MENU_LABEL_VALUE_NETPLAY_ENABLE: return "Netplay Enable"; + case MENU_LABEL_VALUE_SSH_ENABLE: + return "SSH Enable"; case MENU_LABEL_VALUE_NETPLAY_DELAY_FRAMES: return "Netplay Delay Frames"; case MENU_LABEL_VALUE_NETPLAY_MODE: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index a9d4619b82..fb5f445142 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -399,6 +399,8 @@ extern "C" { #define MENU_LABEL_VALUE_AUDIO_LATENCY 0x89900e38U #define MENU_LABEL_NETPLAY_ENABLE 0x607fbd68U #define MENU_LABEL_VALUE_NETPLAY_ENABLE 0xbc3e81a9U +#define MENU_LABEL_SSH_ENABLE 0xd9854a79U +#define MENU_LABEL_VALUE_SSH_ENABLE 0x0430627aU #define MENU_LABEL_NETPLAY_CLIENT_SWAP_INPUT 0xd87bbba9U #define MENU_LABEL_VALUE_NETPLAY_CLIENT_SWAP_INPUT 0x57e5be2dU #define MENU_LABEL_NETPLAY_DELAY_FRAMES 0x86b2c48dU diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 7a92c29884..f887b05e2a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -52,6 +52,7 @@ #include "../input/input_autodetect.h" #include "../config.def.h" #include "../performance.h" +#include "../lakka.h" #include "../tasks/tasks_internal.h" @@ -3079,6 +3080,23 @@ static void overlay_enable_toggle_change_handler(void *data) } #endif +#ifdef HAVE_LAKKA +static void ssh_enable_toggle_change_handler(void *data) +{ + settings_t *settings = config_get_ptr(); + rarch_setting_t *setting = (rarch_setting_t *)data; + + if (!setting) + return; + + if (settings && settings->ssh_enable) + fopen(LAKKA_SSH_PATH, "ab+"); + else + remove(LAKKA_SSH_PATH); + + return; +} +#endif enum settings_list_type { @@ -6500,10 +6518,10 @@ static bool setting_append_list( CONFIG_BOOL( list, list_info, - &global->netplay.enable, - menu_hash_to_str(MENU_LABEL_NETPLAY_ENABLE), - menu_hash_to_str(MENU_LABEL_VALUE_NETPLAY_ENABLE), - false, + &settings->ssh_enable, + menu_hash_to_str(MENU_LABEL_SSH_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_SSH_ENABLE), + true, menu_hash_to_str(MENU_VALUE_OFF), menu_hash_to_str(MENU_VALUE_ON), &group_info, @@ -6511,6 +6529,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); + (*list)[list_info->index - 1].change_handler = ssh_enable_toggle_change_handler; END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); #endif