diff options
| author | 2020-11-30 10:15:00 -0500 | |
|---|---|---|
| committer | 2020-12-18 10:33:28 -0500 | |
| commit | 8b95bf041da573459e953e27eee2dcf30208b02d (patch) | |
| tree | f3213286284f1931b1de5d3af67d1e632d2e1bd1 /src/core | |
| parent | applets/web: Implement the Qt web browser applet frontend (diff) | |
| download | yuzu-8b95bf041da573459e953e27eee2dcf30208b02d.tar.gz yuzu-8b95bf041da573459e953e27eee2dcf30208b02d.tar.xz yuzu-8b95bf041da573459e953e27eee2dcf30208b02d.zip | |
main, applets/web: Re-add progress dialog for RomFS extraction
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/applets/web_browser.cpp | 5 | ||||
| -rw-r--r-- | src/core/frontend/applets/web_browser.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.cpp | 66 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.h | 10 |
4 files changed, 52 insertions, 40 deletions
diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 0e1612e27..a5d8f82ac 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp | |||
| @@ -12,11 +12,12 @@ WebBrowserApplet::~WebBrowserApplet() = default; | |||
| 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; | 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; |
| 13 | 13 | ||
| 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( | 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( |
| 15 | std::string_view local_url, std::function<void(WebExitReason, std::string)> callback) const { | 15 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 16 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | ||
| 16 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", | 17 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", |
| 17 | local_url); | 18 | local_url); |
| 18 | 19 | ||
| 19 | callback(WebExitReason::WindowClosed, "http://localhost/"); | 20 | callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/"); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | } // namespace Core::Frontend | 23 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 2ccefc68f..5b0629cfb 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h | |||
| @@ -9,8 +9,6 @@ | |||
| 9 | 9 | ||
| 10 | #include "core/hle/service/am/applets/web_types.h" | 10 | #include "core/hle/service/am/applets/web_types.h" |
| 11 | 11 | ||
| 12 | using namespace Service::AM::Applets; | ||
| 13 | |||
| 14 | namespace Core::Frontend { | 12 | namespace Core::Frontend { |
| 15 | 13 | ||
| 16 | class WebBrowserApplet { | 14 | class WebBrowserApplet { |
| @@ -18,16 +16,17 @@ public: | |||
| 18 | virtual ~WebBrowserApplet(); | 16 | virtual ~WebBrowserApplet(); |
| 19 | 17 | ||
| 20 | virtual void OpenLocalWebPage( | 18 | virtual void OpenLocalWebPage( |
| 21 | std::string_view local_url, | 19 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 22 | std::function<void(WebExitReason, std::string)> callback) const = 0; | 20 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; |
| 23 | }; | 21 | }; |
| 24 | 22 | ||
| 25 | class DefaultWebBrowserApplet final : public WebBrowserApplet { | 23 | class DefaultWebBrowserApplet final : public WebBrowserApplet { |
| 26 | public: | 24 | public: |
| 27 | ~DefaultWebBrowserApplet() override; | 25 | ~DefaultWebBrowserApplet() override; |
| 28 | 26 | ||
| 29 | void OpenLocalWebPage(std::string_view local_url, | 27 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 30 | std::function<void(WebExitReason, std::string)> callback) const override; | 28 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 29 | callback) const override; | ||
| 31 | }; | 30 | }; |
| 32 | 31 | ||
| 33 | } // namespace Core::Frontend | 32 | } // namespace Core::Frontend |
diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index 02ce9f387..9c8be156f 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include "core/file_sys/registered_cache.h" | 15 | #include "core/file_sys/registered_cache.h" |
| 16 | #include "core/file_sys/romfs.h" | 16 | #include "core/file_sys/romfs.h" |
| 17 | #include "core/file_sys/system_archive/system_archive.h" | 17 | #include "core/file_sys/system_archive/system_archive.h" |
| 18 | #include "core/file_sys/vfs_types.h" | ||
| 19 | #include "core/file_sys/vfs_vector.h" | 18 | #include "core/file_sys/vfs_vector.h" |
| 20 | #include "core/frontend/applets/web_browser.h" | 19 | #include "core/frontend/applets/web_browser.h" |
| 21 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| @@ -311,6 +310,18 @@ void WebBrowser::Execute() { | |||
| 311 | } | 310 | } |
| 312 | } | 311 | } |
| 313 | 312 | ||
| 313 | void WebBrowser::ExtractOfflineRomFS() { | ||
| 314 | LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir); | ||
| 315 | |||
| 316 | const auto extracted_romfs_dir = | ||
| 317 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); | ||
| 318 | |||
| 319 | const auto temp_dir = | ||
| 320 | system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite); | ||
| 321 | |||
| 322 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); | ||
| 323 | } | ||
| 324 | |||
| 314 | void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) { | 325 | void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) { |
| 315 | if ((web_arg_header.shim_kind == ShimKind::Share && | 326 | if ((web_arg_header.shim_kind == ShimKind::Share && |
| 316 | web_applet_version >= WebAppletVersion::Version196608) || | 327 | web_applet_version >= WebAppletVersion::Version196608) || |
| @@ -360,12 +371,11 @@ void WebBrowser::InitializeOffline() { | |||
| 360 | const auto document_kind = | 371 | const auto document_kind = |
| 361 | ParseRawValue<DocumentKind>(GetInputTLVData(WebArgInputTLVType::DocumentKind).value()); | 372 | ParseRawValue<DocumentKind>(GetInputTLVData(WebArgInputTLVType::DocumentKind).value()); |
| 362 | 373 | ||
| 363 | u64 title_id{}; | ||
| 364 | FileSys::ContentRecordType nca_type{FileSys::ContentRecordType::HtmlDocument}; | ||
| 365 | std::string additional_paths; | 374 | std::string additional_paths; |
| 366 | 375 | ||
| 367 | switch (document_kind) { | 376 | switch (document_kind) { |
| 368 | case DocumentKind::OfflineHtmlPage: | 377 | case DocumentKind::OfflineHtmlPage: |
| 378 | default: | ||
| 369 | title_id = system.CurrentProcess()->GetTitleID(); | 379 | title_id = system.CurrentProcess()->GetTitleID(); |
| 370 | nca_type = FileSys::ContentRecordType::HtmlDocument; | 380 | nca_type = FileSys::ContentRecordType::HtmlDocument; |
| 371 | additional_paths = "html-document"; | 381 | additional_paths = "html-document"; |
| @@ -395,31 +405,6 @@ void WebBrowser::InitializeOffline() { | |||
| 395 | offline_document = Common::FS::SanitizePath( | 405 | offline_document = Common::FS::SanitizePath( |
| 396 | fmt::format("{}/{}/{}", offline_cache_dir, additional_paths, document_path), | 406 | fmt::format("{}/{}/{}", offline_cache_dir, additional_paths, document_path), |
| 397 | Common::FS::DirectorySeparator::PlatformDefault); | 407 | Common::FS::DirectorySeparator::PlatformDefault); |
| 398 | |||
| 399 | const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document), | ||
| 400 | Common::FS::DirectorySeparator::PlatformDefault); | ||
| 401 | |||
| 402 | if (Common::FS::Exists(main_url)) { | ||
| 403 | return; | ||
| 404 | } | ||
| 405 | |||
| 406 | auto offline_romfs = GetOfflineRomFS(system, title_id, nca_type); | ||
| 407 | |||
| 408 | if (offline_romfs == nullptr) { | ||
| 409 | LOG_ERROR(Service_AM, "RomFS with title_id={:016X} and nca_type={} cannot be extracted!", | ||
| 410 | title_id, nca_type); | ||
| 411 | return; | ||
| 412 | } | ||
| 413 | |||
| 414 | LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir); | ||
| 415 | |||
| 416 | const auto extracted_romfs_dir = | ||
| 417 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); | ||
| 418 | |||
| 419 | const auto temp_dir = | ||
| 420 | system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite); | ||
| 421 | |||
| 422 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); | ||
| 423 | } | 408 | } |
| 424 | 409 | ||
| 425 | void WebBrowser::InitializeShare() {} | 410 | void WebBrowser::InitializeShare() {} |
| @@ -441,11 +426,28 @@ void WebBrowser::ExecuteLogin() { | |||
| 441 | } | 426 | } |
| 442 | 427 | ||
| 443 | void WebBrowser::ExecuteOffline() { | 428 | void WebBrowser::ExecuteOffline() { |
| 429 | const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document), | ||
| 430 | Common::FS::DirectorySeparator::PlatformDefault); | ||
| 431 | |||
| 432 | if (!Common::FS::Exists(main_url)) { | ||
| 433 | offline_romfs = GetOfflineRomFS(system, title_id, nca_type); | ||
| 434 | |||
| 435 | if (offline_romfs == nullptr) { | ||
| 436 | LOG_ERROR(Service_AM, | ||
| 437 | "RomFS with title_id={:016X} and nca_type={} cannot be extracted!", title_id, | ||
| 438 | nca_type); | ||
| 439 | WebBrowserExit(WebExitReason::WindowClosed); | ||
| 440 | return; | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | LOG_INFO(Service_AM, "Opening offline document at {}", offline_document); | 444 | LOG_INFO(Service_AM, "Opening offline document at {}", offline_document); |
| 445 | frontend.OpenLocalWebPage(offline_document, | 445 | |
| 446 | [this](WebExitReason exit_reason, std::string last_url) { | 446 | frontend.OpenLocalWebPage( |
| 447 | WebBrowserExit(exit_reason, last_url); | 447 | offline_document, [this] { ExtractOfflineRomFS(); }, |
| 448 | }); | 448 | [this](WebExitReason exit_reason, std::string last_url) { |
| 449 | WebBrowserExit(exit_reason, last_url); | ||
| 450 | }); | ||
| 449 | } | 451 | } |
| 450 | 452 | ||
| 451 | void WebBrowser::ExecuteShare() { | 453 | void WebBrowser::ExecuteShare() { |
diff --git a/src/core/hle/service/am/applets/web_browser.h b/src/core/hle/service/am/applets/web_browser.h index c36c717f1..936a49a86 100644 --- a/src/core/hle/service/am/applets/web_browser.h +++ b/src/core/hle/service/am/applets/web_browser.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/file_sys/vfs_types.h" | ||
| 11 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 12 | #include "core/hle/service/am/applets/applets.h" | 13 | #include "core/hle/service/am/applets/applets.h" |
| 13 | #include "core/hle/service/am/applets/web_types.h" | 14 | #include "core/hle/service/am/applets/web_types.h" |
| @@ -16,6 +17,10 @@ namespace Core { | |||
| 16 | class System; | 17 | class System; |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 20 | namespace FileSys { | ||
| 21 | enum class ContentRecordType : u8; | ||
| 22 | } | ||
| 23 | |||
| 19 | namespace Service::AM::Applets { | 24 | namespace Service::AM::Applets { |
| 20 | 25 | ||
| 21 | class WebBrowser final : public Applet { | 26 | class WebBrowser final : public Applet { |
| @@ -31,6 +36,8 @@ public: | |||
| 31 | void ExecuteInteractive() override; | 36 | void ExecuteInteractive() override; |
| 32 | void Execute() override; | 37 | void Execute() override; |
| 33 | 38 | ||
| 39 | void ExtractOfflineRomFS(); | ||
| 40 | |||
| 34 | void WebBrowserExit(WebExitReason exit_reason, std::string last_url = ""); | 41 | void WebBrowserExit(WebExitReason exit_reason, std::string last_url = ""); |
| 35 | 42 | ||
| 36 | private: | 43 | private: |
| @@ -66,8 +73,11 @@ private: | |||
| 66 | WebArgHeader web_arg_header; | 73 | WebArgHeader web_arg_header; |
| 67 | WebArgInputTLVMap web_arg_input_tlv_map; | 74 | WebArgInputTLVMap web_arg_input_tlv_map; |
| 68 | 75 | ||
| 76 | u64 title_id; | ||
| 77 | FileSys::ContentRecordType nca_type; | ||
| 69 | std::string offline_cache_dir; | 78 | std::string offline_cache_dir; |
| 70 | std::string offline_document; | 79 | std::string offline_document; |
| 80 | FileSys::VirtualFile offline_romfs; | ||
| 71 | 81 | ||
| 72 | Core::System& system; | 82 | Core::System& system; |
| 73 | }; | 83 | }; |