(Menu) Lakka Services, allow enabling or disabling SAMBA

This commit is contained in:
Jean-André Santoni 2016-03-23 19:58:01 +07:00
parent 072d6ff125
commit b82976b206
6 changed files with 45 additions and 0 deletions

View File

@ -602,6 +602,7 @@ static void config_set_defaults(void)
#ifdef HAVE_LAKKA
settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH);
settings->samba_enable = path_file_exists(LAKKA_SAMBA_PATH);
#endif
#ifdef HAVE_MENU
@ -1731,6 +1732,7 @@ static bool config_load_file(const char *path, bool set_defaults)
#ifdef HAVE_LAKKA
settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH);
settings->ssh_enable = path_file_exists(LAKKA_SAMBA_PATH);
#endif
#ifdef HAVE_NETWORK_GAMEPAD
@ -2858,6 +2860,10 @@ bool config_save_file(const char *path)
fclose(fopen(LAKKA_SSH_PATH, "w"));
else
remove(LAKKA_SSH_PATH);
if (settings->samba_enable)
fclose(fopen(LAKKA_SAMBA_PATH, "w"));
else
remove(LAKKA_SAMBA_PATH);
#endif
config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio);

View File

@ -402,6 +402,7 @@ typedef struct settings
#ifdef HAVE_LAKKA
bool ssh_enable;
bool samba_enable;
#endif
} settings_t;

View File

@ -18,5 +18,6 @@
#define __RARCH_LAKKA_H
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf"
#endif

View File

@ -264,6 +264,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
return "netplay_enable";
case MENU_LABEL_SSH_ENABLE:
return "ssh_enable";
case MENU_LABEL_SAMBA_ENABLE:
return "samba_enable";
case MENU_LABEL_NETPLAY_DELAY_FRAMES:
return "netplay_delay_frames";
case MENU_LABEL_NETPLAY_MODE:
@ -1012,6 +1014,8 @@ const char *menu_hash_to_str_us(uint32_t hash)
return "Netplay Enable";
case MENU_LABEL_VALUE_SSH_ENABLE:
return "SSH Enable";
case MENU_LABEL_VALUE_SAMBA_ENABLE:
return "SAMBA Enable";
case MENU_LABEL_VALUE_NETPLAY_DELAY_FRAMES:
return "Netplay Delay Frames";
case MENU_LABEL_VALUE_NETPLAY_MODE:

View File

@ -401,6 +401,8 @@ extern "C" {
#define MENU_LABEL_VALUE_NETPLAY_ENABLE 0xbc3e81a9U
#define MENU_LABEL_SSH_ENABLE 0xd9854a79U
#define MENU_LABEL_VALUE_SSH_ENABLE 0x0430627aU
#define MENU_LABEL_SAMBA_ENABLE 0x379e15efU
#define MENU_LABEL_VALUE_SAMBA_ENABLE 0x9846d9b0U
#define MENU_LABEL_NETPLAY_CLIENT_SWAP_INPUT 0xd87bbba9U
#define MENU_LABEL_VALUE_NETPLAY_CLIENT_SWAP_INPUT 0x57e5be2dU
#define MENU_LABEL_NETPLAY_DELAY_FRAMES 0x86b2c48dU

View File

@ -3106,6 +3106,21 @@ static void ssh_enable_toggle_change_handler(void *data)
return;
}
static void samba_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->samba_enable)
fclose(fopen(LAKKA_SAMBA_PATH, "w"));
else
remove(LAKKA_SAMBA_PATH);
return;
}
#endif
enum settings_list_type
@ -6540,6 +6555,22 @@ static bool setting_append_list(
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].change_handler = ssh_enable_toggle_change_handler;
CONFIG_BOOL(
list, list_info,
&settings->samba_enable,
menu_hash_to_str(MENU_LABEL_SAMBA_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_SAMBA_ENABLE),
true,
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);
(*list)[list_info->index - 1].change_handler = samba_enable_toggle_change_handler;
END_SUB_GROUP(list, list_info, parent_group);
END_GROUP(list, list_info, parent_group);
#endif