|
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" |
@@ -3635,6 +3637,53 @@ static void bundle_decompressed(retro_task_t *task, |
3635 | 3637 | command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); |
3636 | 3638 | } |
3637 | 3639 |
|
| 3640 | +#if defined(HAVE_ONLINE_UPDATER) && defined(HAVE_NETWORKING) && defined(HAVE_COMPRESSION) && defined(HAVE_ZLIB) |
| 3641 | +static void menu_download(enum msg_hash_enums enum_idx) |
| 3642 | +{ |
| 3643 | + char s[PATH_MAX_LENGTH]; |
| 3644 | + char s2[PATH_MAX_LENGTH]; |
| 3645 | + char s3[PATH_MAX_LENGTH]; |
| 3646 | + const char *path; |
| 3647 | + file_transfer_t *transf = NULL; |
| 3648 | + settings_t *settings = config_get_ptr(); |
| 3649 | + const char *network_buildbot_assets_url = |
| 3650 | + settings->paths.network_buildbot_assets_url; |
| 3651 | + |
| 3652 | + fill_pathname_join_special(s, |
| 3653 | + network_buildbot_assets_url, |
| 3654 | + "frontend", sizeof(s)); |
| 3655 | + |
| 3656 | + switch (enum_idx) |
| 3657 | + { |
| 3658 | + case MENU_ENUM_LABEL_CB_UPDATE_ASSETS: |
| 3659 | + path = FILE_PATH_ASSETS_ZIP; |
| 3660 | + break; |
| 3661 | + case MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES: |
| 3662 | + path = FILE_PATH_AUTOCONFIG_ZIP; |
| 3663 | + break; |
| 3664 | + case MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES: |
| 3665 | + path = FILE_PATH_CORE_INFO_ZIP; |
| 3666 | + break; |
| 3667 | + case MENU_ENUM_LABEL_CB_UPDATE_DATABASES: |
| 3668 | + path = FILE_PATH_DATABASE_RDB_ZIP; |
| 3669 | + break; |
| 3670 | + case MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS: |
| 3671 | + path = FILE_PATH_OVERLAYS_ZIP; |
| 3672 | + break; |
| 3673 | + default: |
| 3674 | + return; |
| 3675 | + } |
| 3676 | + |
| 3677 | + transf = (file_transfer_t*)calloc(1, sizeof(*transf)); |
| 3678 | + transf->enum_idx = enum_idx; |
| 3679 | + strlcpy(transf->path, path, sizeof(transf->path)); |
| 3680 | + fill_pathname_join_special(s2, s, path, sizeof(s2)); |
| 3681 | + net_http_urlencode_full(s3, s2, sizeof(s3)); |
| 3682 | + task_push_http_transfer_file(s3, false, |
| 3683 | + msg_hash_to_str(enum_idx), cb_generic_download, transf); |
| 3684 | +} |
| 3685 | +#endif |
| 3686 | + |
3638 | 3687 | static bool rarch_menu_init( |
3639 | 3688 | struct menu_state *menu_st, |
3640 | 3689 | menu_dialog_t *p_dialog, |
@@ -3706,6 +3755,29 @@ static bool rarch_menu_init( |
3706 | 3755 | configuration_set_int(settings, |
3707 | 3756 | settings->uints.bundle_assets_extract_last_version, 1); |
3708 | 3757 | } |
| 3758 | +#if defined(HAVE_ONLINE_UPDATER) && defined(HAVE_NETWORKING) && defined(HAVE_ZLIB) |
| 3759 | + else |
| 3760 | + { |
| 3761 | +#ifdef HAVE_UPDATE_ASSETS |
| 3762 | + if (!path_is_directory(settings->paths.directory_assets)) |
| 3763 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_ASSETS); |
| 3764 | +#endif |
| 3765 | + if (!path_is_directory(settings->paths.directory_autoconfig)) |
| 3766 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES); |
| 3767 | +#ifdef HAVE_UPDATE_CORE_INFO |
| 3768 | + if (!path_is_directory(settings->paths.path_libretro_info)) |
| 3769 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES); |
| 3770 | +#endif |
| 3771 | +#ifdef HAVE_LIBRETRODB |
| 3772 | + if (!path_is_directory(settings->paths.path_content_database)) |
| 3773 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_DATABASES); |
| 3774 | +#endif |
| 3775 | +#if defined(RARCH_MOBILE) && defined(HAVE_OVERLAY) |
| 3776 | + if (!path_is_directory(settings->paths.directory_overlay)) |
| 3777 | + menu_download(MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS); |
| 3778 | +#endif |
| 3779 | + } |
| 3780 | +#endif |
3709 | 3781 | #endif |
3710 | 3782 |
|
3711 | 3783 | return true; |
|
0 commit comments