|
40 | 40 |
|
41 | 41 | #ifdef HAVE_NETWORKING |
42 | 42 | #include "../network/netplay/netplay.h" |
| 43 | +#include "../tasks/task_file_transfer.h" |
| 44 | +#include <net/net_http.h> |
43 | 45 | #endif |
44 | 46 |
|
45 | 47 | #include "../audio/audio_driver.h" |
@@ -3627,6 +3629,53 @@ static void bundle_decompressed(retro_task_t *task, |
3627 | 3629 | command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); |
3628 | 3630 | } |
3629 | 3631 |
|
| 3632 | +#if defined(HAVE_ONLINE_UPDATER) && defined(HAVE_NETWORKING) && defined(HAVE_COMPRESSION) && defined(HAVE_ZLIB) |
| 3633 | +static void menu_download(enum msg_hash_enums enum_idx) |
| 3634 | +{ |
| 3635 | + char s[PATH_MAX_LENGTH]; |
| 3636 | + char s2[PATH_MAX_LENGTH]; |
| 3637 | + char s3[PATH_MAX_LENGTH]; |
| 3638 | + const char *path; |
| 3639 | + file_transfer_t *transf = NULL; |
| 3640 | + settings_t *settings = config_get_ptr(); |
| 3641 | + const char *network_buildbot_assets_url = |
| 3642 | + settings->paths.network_buildbot_assets_url; |
| 3643 | + |
| 3644 | + fill_pathname_join_special(s, |
| 3645 | + network_buildbot_assets_url, |
| 3646 | + "frontend", sizeof(s)); |
| 3647 | + |
| 3648 | + switch (enum_idx) |
| 3649 | + { |
| 3650 | + case MENU_ENUM_LABEL_CB_UPDATE_ASSETS: |
| 3651 | + path = FILE_PATH_ASSETS_ZIP; |
| 3652 | + break; |
| 3653 | + case MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES: |
| 3654 | + path = FILE_PATH_AUTOCONFIG_ZIP; |
| 3655 | + break; |
| 3656 | + case MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES: |
| 3657 | + path = FILE_PATH_CORE_INFO_ZIP; |
| 3658 | + break; |
| 3659 | + case MENU_ENUM_LABEL_CB_UPDATE_DATABASES: |
| 3660 | + path = FILE_PATH_DATABASE_RDB_ZIP; |
| 3661 | + break; |
| 3662 | + case MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS: |
| 3663 | + path = FILE_PATH_OVERLAYS_ZIP; |
| 3664 | + break; |
| 3665 | + default: |
| 3666 | + return; |
| 3667 | + } |
| 3668 | + |
| 3669 | + transf = (file_transfer_t*)calloc(1, sizeof(*transf)); |
| 3670 | + transf->enum_idx = enum_idx; |
| 3671 | + strlcpy(transf->path, path, sizeof(transf->path)); |
| 3672 | + fill_pathname_join_special(s2, s, path, sizeof(s2)); |
| 3673 | + net_http_urlencode_full(s3, s2, sizeof(s3)); |
| 3674 | + task_push_http_transfer_file(s3, false, |
| 3675 | + msg_hash_to_str(enum_idx), cb_generic_download, transf); |
| 3676 | +} |
| 3677 | +#endif |
| 3678 | + |
3630 | 3679 | static bool rarch_menu_init( |
3631 | 3680 | struct menu_state *menu_st, |
3632 | 3681 | menu_dialog_t *p_dialog, |
@@ -3698,6 +3747,29 @@ static bool rarch_menu_init( |
3698 | 3747 | configuration_set_int(settings, |
3699 | 3748 | settings->uints.bundle_assets_extract_last_version, 1); |
3700 | 3749 | } |
| 3750 | +#if defined(HAVE_ONLINE_UPDATER) && defined(HAVE_NETWORKING) && defined(HAVE_ZLIB) |
| 3751 | + else |
| 3752 | + { |
| 3753 | +#ifdef HAVE_UPDATE_ASSETS |
| 3754 | + if (!path_is_directory(settings->paths.directory_assets)) |
| 3755 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_ASSETS); |
| 3756 | +#endif |
| 3757 | + if (!path_is_directory(settings->paths.directory_autoconfig)) |
| 3758 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES); |
| 3759 | +#ifdef HAVE_UPDATE_CORE_INFO |
| 3760 | + if (!path_is_directory(settings->paths.path_libretro_info)) |
| 3761 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES); |
| 3762 | +#endif |
| 3763 | +#ifdef HAVE_LIBRETRODB |
| 3764 | + if (!path_is_directory(settings->paths.path_content_database)) |
| 3765 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_DATABASES); |
| 3766 | +#endif |
| 3767 | +#if defined(RARCH_MOBILE) && defined(HAVE_OVERLAY) |
| 3768 | + if (!path_is_directory(settings->paths.directory_overlay)) |
| 3769 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS); |
| 3770 | +#endif |
| 3771 | + } |
| 3772 | +#endif |
3701 | 3773 | #endif |
3702 | 3774 |
|
3703 | 3775 | return true; |
|
0 commit comments