mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
smb: make timeout and num contexts menu options (#18603)
This commit is contained in:
1 parent
e84beb7b85
commit
6e9aa66aea
10 files changed
+115
-18
No files matched your search
@@ -1912,4 +1912,8 @@
|
||||
|
||||
#ifdef HAVE_SMBCLIENT
|
||||
#define DEFAULT_SMB_CLIENT_AUTH_MODE 1
|
||||
#define DEFAULT_SMB_CLIENT_NUM_CONTEXTS 4
|
||||
#define DEFAULT_SMB_CLIENT_MAX_CONTEXTS 20
|
||||
#define DEFAULT_SMB_CLIENT_TIMEOUT 5
|
||||
#define DEFAULT_SMB_CLIENT_MAX_TIMEOUT 20
|
||||
#endif
|
||||
+6
-4
@@ -2685,6 +2685,12 @@ static struct config_uint_setting *populate_settings_uint(
|
||||
SETTING_UINT("input_overlay_mouse_alt_two_touch_input", &settings->uints.input_overlay_mouse_alt_two_touch_input, true, DEFAULT_INPUT_OVERLAY_MOUSE_ALT_TWO_TOUCH_INPUT, false);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SMBCLIENT
|
||||
SETTING_UINT("smb_client_auth_mode", &settings->uints.smb_client_auth_mode, true, DEFAULT_SMB_CLIENT_AUTH_MODE, false);
|
||||
SETTING_UINT("smb_client_num_contexts", &settings->uints.smb_client_num_contexts, true, DEFAULT_SMB_CLIENT_NUM_CONTEXTS, false);
|
||||
SETTING_UINT("smb_client_timeout", &settings->uints.smb_client_timeout, true, DEFAULT_SMB_CLIENT_TIMEOUT, false);
|
||||
#endif
|
||||
|
||||
*size = count;
|
||||
|
||||
return tmp;
|
||||
@@ -2763,10 +2769,6 @@ static struct config_int_setting *populate_settings_int(
|
||||
#endif
|
||||
SETTING_INT("input_turbo_bind", &settings->ints.input_turbo_bind, true, DEFAULT_TURBO_BIND, false);
|
||||
|
||||
#ifdef HAVE_SMBCLIENT
|
||||
SETTING_INT("smb_client_auth_mode", &settings->ints.smb_client_auth_mode, true, DEFAULT_SMB_CLIENT_AUTH_MODE, false);
|
||||
#endif
|
||||
|
||||
*size = count;
|
||||
|
||||
return tmp;
|
||||
|
||||
+6
-3
@@ -155,9 +155,6 @@ typedef struct settings
|
||||
int input_overlay_lightgun_port;
|
||||
#endif
|
||||
int input_turbo_bind;
|
||||
#ifdef HAVE_SMBCLIENT
|
||||
int smb_client_auth_mode;
|
||||
#endif
|
||||
} ints;
|
||||
|
||||
struct
|
||||
@@ -399,6 +396,12 @@ typedef struct settings
|
||||
|
||||
unsigned cheevos_appearance_anchor;
|
||||
unsigned cheevos_visibility_summary;
|
||||
|
||||
#ifdef HAVE_SMBCLIENT
|
||||
unsigned smb_client_auth_mode;
|
||||
unsigned smb_client_num_contexts;
|
||||
unsigned smb_client_timeout;
|
||||
#endif
|
||||
} uints;
|
||||
|
||||
struct
|
||||
|
||||
@@ -6777,6 +6777,14 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_AUTH_MODE,
|
||||
"smb_client_auth_mode"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_NUM_CONTEXTS,
|
||||
"smb_client_num_contexts"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_TIMEOUT,
|
||||
"smb_client_timeout"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_BROWSE,
|
||||
"smb_client_browse"
|
||||
|
||||
@@ -17121,6 +17121,22 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SMB_CLIENT_AUTH_MODE,
|
||||
"Select the authentication used in your environment."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_NUM_CONTEXTS,
|
||||
"SMB Maximum connections"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SMB_CLIENT_NUM_CONTEXTS,
|
||||
"Select the maximum connections used in your environment."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_TIMEOUT,
|
||||
"SMB Timeout"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SMB_CLIENT_TIMEOUT,
|
||||
"Select the default timeout in seconds."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_BROWSE,
|
||||
"Browse SMB Share"
|
||||
|
||||
@@ -27,13 +27,12 @@
|
||||
#include <vfs/vfs_implementation.h>
|
||||
#include "../configuration.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../../config.def.h"
|
||||
#include "vfs_implementation_smb.h"
|
||||
|
||||
#define SMB_PREFIX "smb://"
|
||||
#define MAX_SMB_CONTEXTS 4
|
||||
#define MAX_SMB_TIMEOUT 5
|
||||
|
||||
static struct smb2_context *smb_context_pool[MAX_SMB_CONTEXTS] = {NULL};
|
||||
static struct smb2_context **smb_context_pool = NULL;
|
||||
static int next_context_index = 0;
|
||||
static bool smb_initialized = false;
|
||||
static int max_context_configured = 0;
|
||||
@@ -48,9 +47,18 @@ static struct smb2_context *get_smb_context()
|
||||
if (max_context_configured == 0)
|
||||
return NULL;
|
||||
|
||||
if (next_context_index < 0 || next_context_index >= max_context_configured)
|
||||
next_context_index = 0;
|
||||
|
||||
idx = next_context_index;
|
||||
next_context_index = (next_context_index + 1) % max_context_configured;
|
||||
|
||||
if (!smb_context_pool[idx])
|
||||
{
|
||||
RARCH_ERR("[SMB] Context slot %d is NULL\n", idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return smb_context_pool[idx];
|
||||
}
|
||||
|
||||
@@ -64,7 +72,7 @@ static bool smb_init(void)
|
||||
const char *p;
|
||||
const char *start;
|
||||
size_t len;
|
||||
int i;
|
||||
unsigned i;
|
||||
int error_no = 0;
|
||||
|
||||
if (smb_initialized)
|
||||
@@ -89,7 +97,16 @@ static bool smb_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SMB_CONTEXTS; i++)
|
||||
unsigned max_smb_contexts = settings->uints.smb_client_num_contexts;
|
||||
smb_context_pool = calloc(max_smb_contexts, sizeof(struct smb2_context *));
|
||||
|
||||
if (!smb_context_pool)
|
||||
{
|
||||
RARCH_ERR("[SMB] Failed to allocate context pool\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < max_smb_contexts; i++)
|
||||
{
|
||||
struct smb2_context *smb_context = smb2_init_context();
|
||||
|
||||
@@ -120,10 +137,10 @@ static bool smb_init(void)
|
||||
share[0] = '\0';
|
||||
|
||||
/* set timeout */
|
||||
smb2_set_timeout(smb_context, MAX_SMB_TIMEOUT);
|
||||
smb2_set_timeout(smb_context, settings->uints.smb_client_timeout);
|
||||
|
||||
/* SMB2_SEC_ defines missing on system headers but provided with latest libsmb2 */
|
||||
switch(settings->ints.smb_client_auth_mode)
|
||||
switch(settings->uints.smb_client_auth_mode)
|
||||
{
|
||||
case RETRO_SMB2_SEC_NTLMSSP:
|
||||
smb2_set_security_mode(smb_context, RETRO_SMB2_SEC_NTLMSSP);
|
||||
@@ -206,6 +223,9 @@ void smb_shutdown()
|
||||
smb_close_context(i);
|
||||
}
|
||||
|
||||
free(smb_context_pool);
|
||||
smb_context_pool = NULL;
|
||||
|
||||
smb_initialized = false;
|
||||
next_context_index = 0;
|
||||
max_context_configured = 0;
|
||||
|
||||
@@ -1454,6 +1454,8 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_subdir,
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_username, MENU_ENUM_SUBLABEL_SMB_CLIENT_USERNAME)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_password, MENU_ENUM_SUBLABEL_SMB_CLIENT_PASSWORD)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_workgroup, MENU_ENUM_SUBLABEL_SMB_CLIENT_WORKGROUP)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_num_contexts, MENU_ENUM_SUBLABEL_SMB_CLIENT_NUM_CONTEXTS)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_timeout, MENU_ENUM_SUBLABEL_SMB_CLIENT_TIMEOUT)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_smb_client_browse, MENU_ENUM_SUBLABEL_SMB_CLIENT_BROWSE)
|
||||
#endif
|
||||
|
||||
@@ -5937,6 +5939,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_WORKGROUP:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_smb_client_workgroup);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_NUM_CONTEXTS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_smb_client_num_contexts);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_TIMEOUT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_smb_client_timeout);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_BROWSE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_smb_client_browse);
|
||||
break;
|
||||
|
||||
@@ -12198,7 +12198,9 @@ unsigned menu_displaylist_build_list(
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_USERNAME, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_PASSWORD, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_WORKGROUP, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_AUTH_MODE, PARSE_ONLY_INT, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_AUTH_MODE, PARSE_ONLY_UINT, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_NUM_CONTEXTS, PARSE_ONLY_UINT, false},
|
||||
{MENU_ENUM_LABEL_SMB_CLIENT_TIMEOUT, PARSE_ONLY_UINT, false},
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(build_list); i++)
|
||||
@@ -12212,6 +12214,8 @@ unsigned menu_displaylist_build_list(
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_PASSWORD:
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_WORKGROUP:
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_AUTH_MODE:
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_NUM_CONTEXTS:
|
||||
case MENU_ENUM_LABEL_SMB_CLIENT_TIMEOUT:
|
||||
if (smb_enable)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
|
||||
+33
-3
@@ -8007,7 +8007,7 @@ static int setting_action_right_input_mouse_index(
|
||||
static size_t setting_get_string_representation_smb_auth(
|
||||
rarch_setting_t *setting, char *s, size_t len)
|
||||
{
|
||||
int val;
|
||||
unsigned val;
|
||||
|
||||
if (!setting || !setting->value.target.integer)
|
||||
return 0;
|
||||
@@ -25119,9 +25119,9 @@ static bool setting_append_list(
|
||||
NULL);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ALLOW_INPUT);
|
||||
|
||||
CONFIG_INT(
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->ints.smb_client_auth_mode,
|
||||
&settings->uints.smb_client_auth_mode,
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_AUTH_MODE,
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_AUTH_MODE,
|
||||
DEFAULT_SMB_CLIENT_AUTH_MODE,
|
||||
@@ -25135,6 +25135,36 @@ static bool setting_append_list(
|
||||
&setting_get_string_representation_smb_auth;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, RETRO_SMB2_SEC_KRB5, 1, true, true);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.smb_client_num_contexts,
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_NUM_CONTEXTS,
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_NUM_CONTEXTS,
|
||||
DEFAULT_SMB_CLIENT_NUM_CONTEXTS,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
|
||||
menu_settings_list_current_add_range(list, list_info, 1, DEFAULT_SMB_CLIENT_MAX_CONTEXTS, 1, true, true);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.smb_client_timeout,
|
||||
MENU_ENUM_LABEL_SMB_CLIENT_TIMEOUT,
|
||||
MENU_ENUM_LABEL_VALUE_SMB_CLIENT_TIMEOUT,
|
||||
DEFAULT_SMB_CLIENT_TIMEOUT,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
|
||||
menu_settings_list_current_add_range(list, list_info, 1, DEFAULT_SMB_CLIENT_MAX_TIMEOUT, 1, true, true);
|
||||
|
||||
END_SUB_GROUP(list, list_info, parent_group);
|
||||
END_GROUP(list, list_info, parent_group);
|
||||
break;
|
||||
|
||||
@@ -4339,6 +4339,8 @@ enum msg_hash_enums
|
||||
MENU_LABEL(SMB_CLIENT_USERNAME),
|
||||
MENU_LABEL(SMB_CLIENT_PASSWORD),
|
||||
MENU_LABEL(SMB_CLIENT_WORKGROUP),
|
||||
MENU_LABEL(SMB_CLIENT_NUM_CONTEXTS),
|
||||
MENU_LABEL(SMB_CLIENT_TIMEOUT),
|
||||
MENU_LABEL(SMB_CLIENT_BROWSE),
|
||||
MENU_LABEL(SMB_CLIENT_SMB_SHARE),
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user