mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Start preparing download URL code
This commit is contained in:
parent
f423564895
commit
4eaf718a6e
@ -1550,6 +1550,128 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NETWORKING
|
||||||
|
static int generic_action_ok_network(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
||||||
|
enum msg_hash_enums enum_idx)
|
||||||
|
{
|
||||||
|
char url_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
unsigned type_id2 = 0;
|
||||||
|
const char *url_label = NULL;
|
||||||
|
retro_task_callback_t callback = NULL;
|
||||||
|
bool refresh = true;
|
||||||
|
|
||||||
|
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
|
||||||
|
|
||||||
|
if (string_is_empty(settings->network.buildbot_url))
|
||||||
|
return menu_cbs_exit();
|
||||||
|
|
||||||
|
command_event(CMD_EVENT_NETWORK_INIT, NULL);
|
||||||
|
|
||||||
|
switch (enum_idx)
|
||||||
|
{
|
||||||
|
case MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST:
|
||||||
|
fill_pathname_join(url_path, settings->network.buildbot_assets_url,
|
||||||
|
"cores/.index-dirs", sizeof(url_path));
|
||||||
|
url_label = msg_hash_to_str(enum_idx);
|
||||||
|
type_id2 = ACTION_OK_DL_CORE_CONTENT_DIRS_LIST;
|
||||||
|
callback = cb_net_generic;
|
||||||
|
break;
|
||||||
|
case MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST:
|
||||||
|
fill_pathname_join(url_path, settings->network.buildbot_assets_url,
|
||||||
|
"cores/gw/.index", sizeof(url_path));
|
||||||
|
url_label = msg_hash_to_str(enum_idx);
|
||||||
|
type_id2 = ACTION_OK_DL_CORE_CONTENT_LIST;
|
||||||
|
callback = cb_net_generic;
|
||||||
|
break;
|
||||||
|
case MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST:
|
||||||
|
fill_pathname_join(url_path, settings->network.buildbot_url,
|
||||||
|
file_path_str(FILE_PATH_INDEX_EXTENDED_URL), sizeof(url_path));
|
||||||
|
url_label = msg_hash_to_str(enum_idx);
|
||||||
|
type_id2 = ACTION_OK_DL_CORE_UPDATER_LIST;
|
||||||
|
callback = cb_net_generic;
|
||||||
|
break;
|
||||||
|
case MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST:
|
||||||
|
fill_pathname_join(url_path,
|
||||||
|
file_path_str(FILE_PATH_CORE_THUMBNAILS_URL),
|
||||||
|
file_path_str(FILE_PATH_INDEX_URL), sizeof(url_path));
|
||||||
|
url_label = msg_hash_to_str(enum_idx);
|
||||||
|
type_id2 = ACTION_OK_DL_THUMBNAILS_UPDATER_LIST;
|
||||||
|
callback = cb_net_generic;
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_LAKKA
|
||||||
|
case MENU_ENUM_LABEL_CB_LAKKA_LIST:
|
||||||
|
/* TODO unhardcode this path */
|
||||||
|
fill_pathname_join(url_path,
|
||||||
|
file_path_str(FILE_PATH_LAKKA_URL),
|
||||||
|
LAKKA_PROJECT, sizeof(url_path));
|
||||||
|
fill_pathname_join(url_path, url_path,
|
||||||
|
file_path_str(FILE_PATH_INDEX_URL),
|
||||||
|
sizeof(url_path));
|
||||||
|
url_label = msg_hash_to_str(enum_idx);
|
||||||
|
type_id2 = ACTION_OK_DL_LAKKA_LIST;
|
||||||
|
callback = cb_net_generic;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
task_push_http_transfer(url_path, false, url_label, callback, NULL);
|
||||||
|
|
||||||
|
return generic_action_ok_displaylist_push(path,
|
||||||
|
label, type, idx, entry_idx, type_id2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int action_ok_core_content_list(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
||||||
|
MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int action_ok_core_content_dirs_list(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
||||||
|
MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int action_ok_core_updater_list(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
||||||
|
MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int action_ok_thumbnails_updater_list(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
||||||
|
MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int action_ok_lakka_list(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
||||||
|
MENU_ENUM_LABEL_CB_LAKKA_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cb_generic_dir_download(void *task_data,
|
||||||
|
void *user_data, const char *err)
|
||||||
|
{
|
||||||
|
menu_file_transfer_t *transf = (menu_file_transfer_t*)user_data;
|
||||||
|
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||||
|
|
||||||
|
RARCH_LOG("transf->path: %s\n", transf->path);
|
||||||
|
|
||||||
|
generic_action_ok_network(transf->path, transf->path, 0, 0, 0,
|
||||||
|
MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* expects http_transfer_t*, menu_file_transfer_t* */
|
/* expects http_transfer_t*, menu_file_transfer_t* */
|
||||||
static void cb_generic_download(void *task_data,
|
static void cb_generic_download(void *task_data,
|
||||||
void *user_data, const char *err)
|
void *user_data, const char *err)
|
||||||
@ -1700,116 +1822,6 @@ finish:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
static int generic_action_ok_network(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
|
||||||
enum msg_hash_enums enum_idx)
|
|
||||||
{
|
|
||||||
char url_path[PATH_MAX_LENGTH] = {0};
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
unsigned type_id2 = 0;
|
|
||||||
const char *url_label = NULL;
|
|
||||||
retro_task_callback_t callback = NULL;
|
|
||||||
bool refresh = true;
|
|
||||||
|
|
||||||
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
|
|
||||||
|
|
||||||
if (string_is_empty(settings->network.buildbot_url))
|
|
||||||
return menu_cbs_exit();
|
|
||||||
|
|
||||||
command_event(CMD_EVENT_NETWORK_INIT, NULL);
|
|
||||||
|
|
||||||
switch (enum_idx)
|
|
||||||
{
|
|
||||||
case MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST:
|
|
||||||
fill_pathname_join(url_path, settings->network.buildbot_assets_url,
|
|
||||||
"cores/.index-dirs", sizeof(url_path));
|
|
||||||
url_label = msg_hash_to_str(enum_idx);
|
|
||||||
type_id2 = ACTION_OK_DL_CORE_CONTENT_DIRS_LIST;
|
|
||||||
callback = cb_net_generic;
|
|
||||||
break;
|
|
||||||
case MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST:
|
|
||||||
fill_pathname_join(url_path, settings->network.buildbot_assets_url,
|
|
||||||
"cores/gw/.index", sizeof(url_path));
|
|
||||||
url_label = msg_hash_to_str(enum_idx);
|
|
||||||
type_id2 = ACTION_OK_DL_CORE_CONTENT_LIST;
|
|
||||||
callback = cb_net_generic;
|
|
||||||
break;
|
|
||||||
case MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST:
|
|
||||||
fill_pathname_join(url_path, settings->network.buildbot_url,
|
|
||||||
file_path_str(FILE_PATH_INDEX_EXTENDED_URL), sizeof(url_path));
|
|
||||||
url_label = msg_hash_to_str(enum_idx);
|
|
||||||
type_id2 = ACTION_OK_DL_CORE_UPDATER_LIST;
|
|
||||||
callback = cb_net_generic;
|
|
||||||
break;
|
|
||||||
case MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST:
|
|
||||||
fill_pathname_join(url_path,
|
|
||||||
file_path_str(FILE_PATH_CORE_THUMBNAILS_URL),
|
|
||||||
file_path_str(FILE_PATH_INDEX_URL), sizeof(url_path));
|
|
||||||
url_label = msg_hash_to_str(enum_idx);
|
|
||||||
type_id2 = ACTION_OK_DL_THUMBNAILS_UPDATER_LIST;
|
|
||||||
callback = cb_net_generic;
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_LAKKA
|
|
||||||
case MENU_ENUM_LABEL_CB_LAKKA_LIST:
|
|
||||||
/* TODO unhardcode this path */
|
|
||||||
fill_pathname_join(url_path,
|
|
||||||
file_path_str(FILE_PATH_LAKKA_URL),
|
|
||||||
LAKKA_PROJECT, sizeof(url_path));
|
|
||||||
fill_pathname_join(url_path, url_path,
|
|
||||||
file_path_str(FILE_PATH_INDEX_URL),
|
|
||||||
sizeof(url_path));
|
|
||||||
url_label = msg_hash_to_str(enum_idx);
|
|
||||||
type_id2 = ACTION_OK_DL_LAKKA_LIST;
|
|
||||||
callback = cb_net_generic;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
task_push_http_transfer(url_path, false, url_label, callback, NULL);
|
|
||||||
|
|
||||||
return generic_action_ok_displaylist_push(path,
|
|
||||||
label, type, idx, entry_idx, type_id2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int action_ok_core_content_list(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
|
||||||
{
|
|
||||||
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
|
||||||
MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int action_ok_core_content_dirs_list(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
|
||||||
{
|
|
||||||
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
|
||||||
MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int action_ok_core_updater_list(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
|
||||||
{
|
|
||||||
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
|
||||||
MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int action_ok_thumbnails_updater_list(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
|
||||||
{
|
|
||||||
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
|
||||||
MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int action_ok_lakka_list(const char *path,
|
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
|
||||||
{
|
|
||||||
return generic_action_ok_network(path, label, type, idx, entry_idx,
|
|
||||||
MENU_ENUM_LABEL_CB_LAKKA_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int action_ok_download_generic(const char *path,
|
static int action_ok_download_generic(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
||||||
@ -1820,18 +1832,19 @@ static int action_ok_download_generic(const char *path,
|
|||||||
char s3[PATH_MAX_LENGTH] = {0};
|
char s3[PATH_MAX_LENGTH] = {0};
|
||||||
menu_file_transfer_t *transf = NULL;
|
menu_file_transfer_t *transf = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
retro_task_callback_t cb = cb_generic_download;
|
||||||
|
|
||||||
fill_pathname_join(s, settings->network.buildbot_assets_url,
|
fill_pathname_join(s, settings->network.buildbot_assets_url,
|
||||||
"frontend", sizeof(s));
|
"frontend", sizeof(s));
|
||||||
|
|
||||||
|
|
||||||
switch (enum_idx)
|
switch (enum_idx)
|
||||||
{
|
{
|
||||||
case MENU_ENUM_LABEL_CB_DOWNLOAD_URL:
|
case MENU_ENUM_LABEL_CB_DOWNLOAD_URL:
|
||||||
fill_pathname_join(s, label,
|
fill_pathname_join(s, label,
|
||||||
path, sizeof(s));
|
path, sizeof(s));
|
||||||
return generic_action_ok_network(s, label, type, idx, entry_idx,
|
path = strdup(s);
|
||||||
MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST);
|
cb = cb_generic_dir_download;
|
||||||
|
break;
|
||||||
case MENU_ENUM_LABEL_CB_CORE_CONTENT_DOWNLOAD:
|
case MENU_ENUM_LABEL_CB_CORE_CONTENT_DOWNLOAD:
|
||||||
fill_pathname_join(s, settings->network.buildbot_assets_url,
|
fill_pathname_join(s, settings->network.buildbot_assets_url,
|
||||||
"cores/gw", sizeof(s));
|
"cores/gw", sizeof(s));
|
||||||
@ -1881,7 +1894,7 @@ static int action_ok_download_generic(const char *path,
|
|||||||
transf->enum_idx = enum_idx;
|
transf->enum_idx = enum_idx;
|
||||||
strlcpy(transf->path, path, sizeof(transf->path));
|
strlcpy(transf->path, path, sizeof(transf->path));
|
||||||
|
|
||||||
task_push_http_transfer(s3, false, msg_hash_to_str(enum_idx), cb_generic_download, transf);
|
task_push_http_transfer(s3, false, msg_hash_to_str(enum_idx), cb, transf);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user