From 1cb8faf6c939857ccebe87ceef1b22b5456f7c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 22 Mar 2016 03:31:34 +0700 Subject: [PATCH 1/5] (Menu) Add a setting group for Lakka Services --- menu/intl/menu_hash_us.c | 2 ++ menu/menu_displaylist.c | 2 ++ menu/menu_hash.h | 1 + menu/menu_setting.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index f58f755653..80e199366c 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -1636,6 +1636,8 @@ const char *menu_hash_to_str_us(uint32_t hash) return "Updater"; case MENU_LABEL_VALUE_NETWORK_SETTINGS: return "Network"; + case MENU_LABEL_VALUE_LAKKA_SERVICES: + return "Lakka Services"; case MENU_LABEL_VALUE_PLAYLIST_SETTINGS: return "Playlists"; case MENU_LABEL_VALUE_USER_SETTINGS: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 9b7fb9f52a..d204ee9dc9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3345,6 +3345,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_hash_to_str(MENU_LABEL_VALUE_CORE_UPDATER_SETTINGS), PARSE_ONLY_GROUP, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_VALUE_NETWORK_SETTINGS), PARSE_ONLY_GROUP, false); + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_VALUE_LAKKA_SERVICES), PARSE_ONLY_GROUP, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_PLAYLIST_SETTINGS), PARSE_ACTION, false); ret = menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 6e16abc243..a9d4619b82 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -897,6 +897,7 @@ extern "C" { #define MENU_LABEL_VALUE_CORE_UPDATER_SETTINGS 0x124ad454U #define MENU_LABEL_NETWORK_SETTINGS 0x8b50d180U #define MENU_LABEL_VALUE_NETWORK_SETTINGS 0x8b50d180U +#define MENU_LABEL_VALUE_LAKKA_SERVICES 0x0c113d6dU #define MENU_LABEL_ARCHIVE_SETTINGS 0x78e85398U #define MENU_LABEL_USER_SETTINGS 0xcdc9a8f5U #define MENU_LABEL_VALUE_USER_SETTINGS 0xcdc9a8f5U diff --git a/menu/menu_setting.c b/menu/menu_setting.c index de569afa18..7a92c29884 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3106,6 +3106,7 @@ enum settings_list_type SETTINGS_LIST_CHEEVOS, SETTINGS_LIST_CORE_UPDATER, SETTINGS_LIST_NETPLAY, + SETTINGS_LIST_LAKKA_SERVICES, SETTINGS_LIST_USER, SETTINGS_LIST_USER_ACCOUNTS, SETTINGS_LIST_USER_ACCOUNTS_CHEEVOS, @@ -6483,6 +6484,35 @@ static bool setting_append_list( #endif END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); +#endif + } + break; + case SETTINGS_LIST_LAKKA_SERVICES: + { +#if defined(HAVE_LAKKA) + START_GROUP(list, list_info, &group_info, + menu_hash_to_str(MENU_LABEL_VALUE_LAKKA_SERVICES), + parent_group); + + parent_group = menu_hash_to_str(MENU_LABEL_VALUE_SETTINGS); + + START_SUB_GROUP(list, list_info, "Lakka Services", &group_info, &subgroup_info, parent_group); + + 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, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + END_SUB_GROUP(list, list_info, parent_group); + END_GROUP(list, list_info, parent_group); #endif } break; @@ -7216,6 +7246,7 @@ static rarch_setting_t *menu_setting_new_internal(rarch_setting_info_t *list_inf SETTINGS_LIST_CHEEVOS, SETTINGS_LIST_CORE_UPDATER, SETTINGS_LIST_NETPLAY, + SETTINGS_LIST_LAKKA_SERVICES, SETTINGS_LIST_USER, SETTINGS_LIST_USER_ACCOUNTS, SETTINGS_LIST_USER_ACCOUNTS_CHEEVOS, 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 2/5] (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 From d5816cb298a45e5f2ffd159fa3d607c261f67fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 22 Mar 2016 17:10:06 +0700 Subject: [PATCH 3/5] (Menu) More ifdef for Lakka Services, and create files with w mode. --- menu/menu_displaylist.c | 2 ++ menu/menu_setting.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index d204ee9dc9..6bf348debb 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3345,8 +3345,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_hash_to_str(MENU_LABEL_VALUE_CORE_UPDATER_SETTINGS), PARSE_ONLY_GROUP, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_VALUE_NETWORK_SETTINGS), PARSE_ONLY_GROUP, false); +#ifdef HAVE_LAKKA ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_VALUE_LAKKA_SERVICES), PARSE_ONLY_GROUP, false); +#endif ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_PLAYLIST_SETTINGS), PARSE_ACTION, false); ret = menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f887b05e2a..f848281bcd 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3090,7 +3090,7 @@ static void ssh_enable_toggle_change_handler(void *data) return; if (settings && settings->ssh_enable) - fopen(LAKKA_SSH_PATH, "ab+"); + fopen(LAKKA_SSH_PATH, "w"); else remove(LAKKA_SSH_PATH); From 6b3a8112d1bd6939e07373075609b105b5242435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Wed, 23 Mar 2016 01:23:51 +0700 Subject: [PATCH 4/5] (Menu) Fixes for Lakka Services --- configuration.c | 2 +- menu/menu_setting.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 1c9a2683bb..18c68f3480 100644 --- a/configuration.c +++ b/configuration.c @@ -2855,7 +2855,7 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->ssh_enable) - fopen(LAKKA_SSH_PATH, "ab+"); + fclose(LAKKA_SSH_PATH, "w"); else remove(LAKKA_SSH_PATH); #endif diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f848281bcd..0a190275f1 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3090,7 +3090,7 @@ static void ssh_enable_toggle_change_handler(void *data) return; if (settings && settings->ssh_enable) - fopen(LAKKA_SSH_PATH, "w"); + fclose(LAKKA_SSH_PATH, "w"); else remove(LAKKA_SSH_PATH); From 60f9f8329c7b2c9b25de0a776e058a30ac96cc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Wed, 23 Mar 2016 01:25:27 +0700 Subject: [PATCH 5/5] (Menu) Forgot that --- configuration.c | 2 +- menu/menu_setting.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 18c68f3480..8507187e07 100644 --- a/configuration.c +++ b/configuration.c @@ -2855,7 +2855,7 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->ssh_enable) - fclose(LAKKA_SSH_PATH, "w"); + fclose(fopen(LAKKA_SSH_PATH, "w")); else remove(LAKKA_SSH_PATH); #endif diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0a190275f1..d07081eed6 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3090,7 +3090,7 @@ static void ssh_enable_toggle_change_handler(void *data) return; if (settings && settings->ssh_enable) - fclose(LAKKA_SSH_PATH, "w"); + fclose(fopen(LAKKA_SSH_PATH, "w")); else remove(LAKKA_SSH_PATH);