diff --git a/Makefile.common b/Makefile.common index 7d5f843015..b70cc3d36a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1907,9 +1907,7 @@ ifeq ($(HAVE_NETWORKING), 1) tasks/task_netplay_find_content.o ifeq ($(HAVE_MENU_COMMON), 1) - OBJ += \ - tasks/task_core_updater.o \ - menu/menu_networking.o + OBJ += tasks/task_core_updater.o endif ifeq ($(HAVE_SSL), 1) diff --git a/griffin/griffin.c b/griffin/griffin.c index 8c1bc8d5ca..b5586d7a89 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1350,10 +1350,6 @@ MENU #ifdef HAVE_MENU #include "../menu/menu_setting.c" -#if defined(HAVE_NETWORKING) -#include "../menu/menu_networking.c" -#endif - #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" #include "../menu/cbs/menu_cbs_select.c" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index bed19a583e..663b3bf9d1 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -50,7 +50,6 @@ #include "../menu_dialog.h" #include "../menu_input_bind_dialog.h" #include "../menu_input.h" -#include "../menu_networking.h" #include "../../core.h" #include "../../configuration.h" @@ -4090,6 +4089,126 @@ static int action_ok_core_updater_list(const char *path, ACTION_OK_DL_CORE_UPDATER_LIST); } +static void cb_net_generic_subdir(retro_task_t *task, + void *task_data, void *user_data, const char *err) +{ + char subdir_path[PATH_MAX_LENGTH]; + http_transfer_data_t *data = (http_transfer_data_t*)task_data; + file_transfer_t *state = (file_transfer_t*)user_data; + + subdir_path[0] = '\0'; + + if (!data || err) + goto finish; + + if (!string_is_empty(data->data)) + memcpy(subdir_path, data->data, data->len * sizeof(char)); + subdir_path[data->len] = '\0'; + +finish: + if (!err && !string_ends_with_size(subdir_path, + FILE_PATH_INDEX_DIRS_URL, + strlen(subdir_path), + STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) + )) + { + char parent_dir[PATH_MAX_LENGTH]; + + parent_dir[0] = '\0'; + + fill_pathname_parent_dir(parent_dir, + state->path, sizeof(parent_dir)); + + /*generic_action_ok_displaylist_push(parent_dir, NULL, + subdir_path, 0, 0, 0, ACTION_OK_DL_CORE_CONTENT_DIRS_SUBDIR_LIST);*/ + } + + if (data) + { + if (data->data) + free(data->data); + free(data); + } + + if (user_data) + free(user_data); +} + +static void cb_net_generic(retro_task_t *task, + void *task_data, void *user_data, const char *err) +{ + bool refresh = false; + http_transfer_data_t *data = (http_transfer_data_t*)task_data; + file_transfer_t *state = (file_transfer_t*)user_data; + menu_handle_t *menu = menu_driver_get_ptr(); + + if (!menu) + goto finish; + + if (menu->core_buf) + free(menu->core_buf); + + menu->core_buf = NULL; + menu->core_len = 0; + + if (!data || err) + goto finish; + + menu->core_buf = (char*)malloc((data->len+1) * sizeof(char)); + + if (!menu->core_buf) + goto finish; + + if (!string_is_empty(data->data)) + memcpy(menu->core_buf, data->data, data->len * sizeof(char)); + menu->core_buf[data->len] = '\0'; + menu->core_len = data->len; + +finish: + refresh = true; + menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh); + + if (data) + { + if (data->data) + free(data->data); + free(data); + } + + if (!err && + !string_ends_with_size(state->path, + FILE_PATH_INDEX_DIRS_URL, + strlen(state->path), + STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) + )) + { + char parent_dir[PATH_MAX_LENGTH]; + char parent_dir_encoded[PATH_MAX_LENGTH]; + file_transfer_t *transf = NULL; + + parent_dir[0] = '\0'; + parent_dir_encoded[0] = '\0'; + + fill_pathname_parent_dir(parent_dir, + state->path, sizeof(parent_dir)); + strlcat(parent_dir, FILE_PATH_INDEX_DIRS_URL, + sizeof(parent_dir)); + + transf = (file_transfer_t*)malloc(sizeof(*transf)); + + transf->enum_idx = MSG_UNKNOWN; + strlcpy(transf->path, parent_dir, sizeof(transf->path)); + + net_http_urlencode_full(parent_dir_encoded, parent_dir, + sizeof(parent_dir_encoded)); + task_push_http_transfer_file(parent_dir_encoded, true, + "index_dirs", cb_net_generic_subdir, transf); + } + + if (state) + free(state); +} + 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) @@ -4120,26 +4239,26 @@ static int generic_action_ok_network(const char *path, network_buildbot_assets_url, "cores/" FILE_PATH_INDEX_DIRS_URL, sizeof(url_path)); - url_label = msg_hash_to_str(enum_idx); - type_id2 = ACTION_OK_DL_CORE_CONTENT_DIRS_LIST; - callback = cb_net_generic; + url_label = msg_hash_to_str(enum_idx); + type_id2 = ACTION_OK_DL_CORE_CONTENT_DIRS_LIST; + callback = cb_net_generic; suppress_msg = true; break; case MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST: fill_pathname_join(url_path, path, FILE_PATH_INDEX_URL, sizeof(url_path)); - url_label = msg_hash_to_str(enum_idx); - type_id2 = ACTION_OK_DL_CORE_CONTENT_LIST; - callback = cb_net_generic; + url_label = msg_hash_to_str(enum_idx); + type_id2 = ACTION_OK_DL_CORE_CONTENT_LIST; + callback = cb_net_generic; suppress_msg = true; break; case MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST: fill_pathname_join(url_path, FILE_PATH_CORE_THUMBNAILPACKS_URL, 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; + 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: @@ -4150,9 +4269,9 @@ static int generic_action_ok_network(const char *path, fill_pathname_join(url_path, url_path, 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; + url_label = msg_hash_to_str(enum_idx); + type_id2 = ACTION_OK_DL_LAKKA_LIST; + callback = cb_net_generic; break; #endif default: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 150df32697..d0541a00c7 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -77,7 +77,6 @@ #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #include "menu_shader.h" #endif -#include "menu_networking.h" #include "menu_dialog.h" #include "../configuration.h" @@ -8915,6 +8914,104 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) return count; } + +static unsigned print_buf_lines(file_list_t *list, char *buf, + const char *label, int buf_size, + enum msg_file_type type, bool append, bool extended) +{ + char c; + unsigned count = 0; + int i = 0; + char *line_start = buf; + + if (!buf || !buf_size) + return 0; + + for (i = 0; i < buf_size; i++) + { + size_t ln; + const char *core_date = NULL; + const char *core_crc = NULL; + const char *core_pathname = NULL; + struct string_list str_list = {0}; + + /* The end of the buffer, print the last bit */ + if (*(buf + i) == '\0') + break; + + if (*(buf + i) != '\n') + continue; + + /* Found a line ending, print the line and compute new line_start */ + + /* Save the next char */ + c = *(buf + i + 1); + /* replace with \0 */ + *(buf + i + 1) = '\0'; + + /* We need to strip the newline. */ + ln = strlen(line_start) - 1; + if (line_start[ln] == '\n') + line_start[ln] = '\0'; + + string_list_initialize(&str_list); + string_split_noalloc(&str_list, line_start, " "); + + if (str_list.elems[0].data) + core_date = str_list.elems[0].data; + if (str_list.elems[1].data) + core_crc = str_list.elems[1].data; + if (str_list.elems[2].data) + core_pathname = str_list.elems[2].data; + + (void)core_date; + (void)core_crc; + + if (extended) + { + if (append) + { + if (menu_entries_append_enum(list, core_pathname, "", + MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0)) + count++; + } + else + { + menu_entries_prepend(list, core_pathname, "", + MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); + count++; + } + } + else + { + if (append) + { + if (menu_entries_append_enum(list, line_start, label, + MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0)) + count++; + } + else + { + menu_entries_prepend(list, line_start, label, + MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); + count++; + } + } + + string_list_deinitialize(&str_list); + + /* Restore the saved char */ + *(buf + i + 1) = c; + line_start = buf + i + 1; + } + + if (append) + file_list_sort_on_alt(list); + /* If the buffer was completely full, and didn't end + * with a newline, just ignore the partial last line. */ + + return count; +} #endif bool menu_displaylist_has_subsystems(void) diff --git a/menu/menu_networking.c b/menu/menu_networking.c deleted file mode 100644 index 7a3cf08495..0000000000 --- a/menu/menu_networking.c +++ /dev/null @@ -1,261 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-André Santoni - * Copyright (C) 2016-2019 - Andrés Suárez - * Copyright (C) 2016-2019 - Brad Parker - * - * 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 . - */ - -#include - -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_NETWORKING -#include -#endif - -#include "menu_driver.h" -#include "menu_networking.h" -#include "menu_entries.h" - -#include "../file_path_special.h" -#include "../msg_hash.h" -#include "../tasks/task_file_transfer.h" -#include "../tasks/tasks_internal.h" - -unsigned print_buf_lines(file_list_t *list, char *buf, - const char *label, int buf_size, - enum msg_file_type type, bool append, bool extended) -{ - char c; - unsigned count = 0; - int i = 0; - char *line_start = buf; - - if (!buf || !buf_size) - return 0; - - for (i = 0; i < buf_size; i++) - { - size_t ln; - const char *core_date = NULL; - const char *core_crc = NULL; - const char *core_pathname = NULL; - struct string_list str_list = {0}; - - /* The end of the buffer, print the last bit */ - if (*(buf + i) == '\0') - break; - - if (*(buf + i) != '\n') - continue; - - /* Found a line ending, print the line and compute new line_start */ - - /* Save the next char */ - c = *(buf + i + 1); - /* replace with \0 */ - *(buf + i + 1) = '\0'; - - /* We need to strip the newline. */ - ln = strlen(line_start) - 1; - if (line_start[ln] == '\n') - line_start[ln] = '\0'; - - string_list_initialize(&str_list); - string_split_noalloc(&str_list, line_start, " "); - - if (str_list.elems[0].data) - core_date = str_list.elems[0].data; - if (str_list.elems[1].data) - core_crc = str_list.elems[1].data; - if (str_list.elems[2].data) - core_pathname = str_list.elems[2].data; - - (void)core_date; - (void)core_crc; - - if (extended) - { - if (append) - { - if (menu_entries_append_enum(list, core_pathname, "", - MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0)) - count++; - } - else - { - menu_entries_prepend(list, core_pathname, "", - MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); - count++; - } - } - else - { - if (append) - { - if (menu_entries_append_enum(list, line_start, label, - MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0)) - count++; - } - else - { - menu_entries_prepend(list, line_start, label, - MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0); - count++; - } - } - - string_list_deinitialize(&str_list); - - /* Restore the saved char */ - *(buf + i + 1) = c; - line_start = buf + i + 1; - } - - if (append) - file_list_sort_on_alt(list); - /* If the buffer was completely full, and didn't end - * with a newline, just ignore the partial last line. */ - - return count; -} - -void cb_net_generic_subdir(retro_task_t *task, - void *task_data, void *user_data, const char *err) -{ -#ifdef HAVE_NETWORKING - char subdir_path[PATH_MAX_LENGTH]; - http_transfer_data_t *data = (http_transfer_data_t*)task_data; - file_transfer_t *state = (file_transfer_t*)user_data; - - subdir_path[0] = '\0'; - - if (!data || err) - goto finish; - - if (!string_is_empty(data->data)) - memcpy(subdir_path, data->data, data->len * sizeof(char)); - subdir_path[data->len] = '\0'; - -finish: - if (!err && !string_ends_with_size(subdir_path, - FILE_PATH_INDEX_DIRS_URL, - strlen(subdir_path), - STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) - )) - { - char parent_dir[PATH_MAX_LENGTH]; - - parent_dir[0] = '\0'; - - fill_pathname_parent_dir(parent_dir, - state->path, sizeof(parent_dir)); - - /*generic_action_ok_displaylist_push(parent_dir, NULL, - subdir_path, 0, 0, 0, ACTION_OK_DL_CORE_CONTENT_DIRS_SUBDIR_LIST);*/ - } - - if (data) - { - if (data->data) - free(data->data); - free(data); - } - - if (user_data) - free(user_data); -#endif -} - -void cb_net_generic(retro_task_t *task, - void *task_data, void *user_data, const char *err) -{ -#ifdef HAVE_NETWORKING - bool refresh = false; - http_transfer_data_t *data = (http_transfer_data_t*)task_data; - file_transfer_t *state = (file_transfer_t*)user_data; - menu_handle_t *menu = menu_driver_get_ptr(); - - if (!menu) - goto finish; - - if (menu->core_buf) - free(menu->core_buf); - - menu->core_buf = NULL; - menu->core_len = 0; - - if (!data || err) - goto finish; - - menu->core_buf = (char*)malloc((data->len+1) * sizeof(char)); - - if (!menu->core_buf) - goto finish; - - if (!string_is_empty(data->data)) - memcpy(menu->core_buf, data->data, data->len * sizeof(char)); - menu->core_buf[data->len] = '\0'; - menu->core_len = data->len; - -finish: - refresh = true; - menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh); - - if (data) - { - if (data->data) - free(data->data); - free(data); - } - - if (!err && - !string_ends_with_size(state->path, - FILE_PATH_INDEX_DIRS_URL, - strlen(state->path), - STRLEN_CONST(FILE_PATH_INDEX_DIRS_URL) - )) - { - char parent_dir[PATH_MAX_LENGTH]; - char parent_dir_encoded[PATH_MAX_LENGTH]; - file_transfer_t *transf = NULL; - - parent_dir[0] = '\0'; - parent_dir_encoded[0] = '\0'; - - fill_pathname_parent_dir(parent_dir, - state->path, sizeof(parent_dir)); - strlcat(parent_dir, FILE_PATH_INDEX_DIRS_URL, - sizeof(parent_dir)); - - transf = (file_transfer_t*)malloc(sizeof(*transf)); - - transf->enum_idx = MSG_UNKNOWN; - strlcpy(transf->path, parent_dir, sizeof(transf->path)); - - net_http_urlencode_full(parent_dir_encoded, parent_dir, - sizeof(parent_dir_encoded)); - task_push_http_transfer_file(parent_dir_encoded, true, - "index_dirs", cb_net_generic_subdir, transf); - } - - if (state) - free(state); -#endif -} diff --git a/menu/menu_networking.h b/menu/menu_networking.h deleted file mode 100644 index f6283755af..0000000000 --- a/menu/menu_networking.h +++ /dev/null @@ -1,45 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2016-2019 - Brad Parker - * - * 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 _MENU_NETWORKING_H -#define _MENU_NETWORKING_H - -#include - -#include -#include - -#include - -#include "../msg_hash.h" - -RETRO_BEGIN_DECLS - -unsigned print_buf_lines(file_list_t *list, char *buf, - const char *label, int buf_size, - enum msg_file_type type, bool append, bool extended); - -void cb_net_generic_subdir(retro_task_t *task, - void *task_data, void *user_data, - const char *err); - -void cb_net_generic(retro_task_t *task, - void *task_data, void *user_data, const char *err); - -RETRO_END_DECLS - -#endif diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index 105653c3a1..22157638d6 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -199,7 +199,6 @@ 05A8C53E20DB72F000FF7857 /* null.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = null.c; sourceTree = ""; }; 05A8C54020DB72F000FF7857 /* materialui.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = materialui.c; sourceTree = ""; }; 05A8C54120DB72F000FF7857 /* menu_cbs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_cbs.c; sourceTree = ""; }; - 05A8C54220DB72F000FF7857 /* menu_networking.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_networking.h; sourceTree = ""; }; 05A8C54320DB72F000FF7857 /* menu_driver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_driver.h; sourceTree = ""; }; 05A8C54520DB72F000FF7857 /* menu_entries.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_entries.c; sourceTree = ""; }; 05A8C54620DB72F000FF7857 /* menu_setting.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_setting.c; sourceTree = ""; }; @@ -209,7 +208,6 @@ 05A8C54B20DB72F000FF7857 /* gfx_animation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gfx_animation.h; sourceTree = ""; }; 05A8C54C20DB72F000FF7857 /* menu_cbs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_cbs.h; sourceTree = ""; }; 05A8C54D20DB72F000FF7857 /* menu_driver.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_driver.c; sourceTree = ""; }; - 05A8C54F20DB72F000FF7857 /* menu_networking.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_networking.c; sourceTree = ""; }; 05A8C55020DB72F000FF7857 /* menu_input.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_input.h; sourceTree = ""; }; 05A8C55120DB72F000FF7857 /* menu_setting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_setting.h; sourceTree = ""; }; 05A8C55320DB72F000FF7857 /* menu_input_bind_dialog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_input_bind_dialog.h; sourceTree = ""; }; @@ -765,8 +763,6 @@ 05A8C57020DB72F000FF7857 /* menu_entries.h */, 05A8C54720DB72F000FF7857 /* menu_input.c */, 05A8C55020DB72F000FF7857 /* menu_input.h */, - 05A8C54F20DB72F000FF7857 /* menu_networking.c */, - 05A8C54220DB72F000FF7857 /* menu_networking.h */, 05A8C54620DB72F000FF7857 /* menu_setting.c */, 05A8C55120DB72F000FF7857 /* menu_setting.h */, 05A8C54A20DB72F000FF7857 /* menu_shader.c */,