summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Morph2020-11-30 10:15:00 -0500
committerGravatar Morph2020-12-18 10:33:28 -0500
commit8b95bf041da573459e953e27eee2dcf30208b02d (patch)
treef3213286284f1931b1de5d3af67d1e632d2e1bd1 /src/core/hle
parentapplets/web: Implement the Qt web browser applet frontend (diff)
downloadyuzu-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/hle')
-rw-r--r--src/core/hle/service/am/applets/web_browser.cpp66
-rw-r--r--src/core/hle/service/am/applets/web_browser.h10
2 files changed, 44 insertions, 32 deletions
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
313void 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
314void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) { 325void 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
425void WebBrowser::InitializeShare() {} 410void WebBrowser::InitializeShare() {}
@@ -441,11 +426,28 @@ void WebBrowser::ExecuteLogin() {
441} 426}
442 427
443void WebBrowser::ExecuteOffline() { 428void 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
451void WebBrowser::ExecuteShare() { 453void 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 {
16class System; 17class System;
17} 18}
18 19
20namespace FileSys {
21enum class ContentRecordType : u8;
22}
23
19namespace Service::AM::Applets { 24namespace Service::AM::Applets {
20 25
21class WebBrowser final : public Applet { 26class 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
36private: 43private:
@@ -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};