From d1abe8e92afd6d03324af5733660aca2a77f134b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 11 Jul 2019 00:53:55 -0400 Subject: service/am: Remove usages of global system accessors Avoids the use of global accessors, removing the reliance on global state. This also makes dependencies explicit in the interface, as opposed to being hidden --- src/core/hle/service/am/applets/applets.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/core/hle/service/am/applets/applets.cpp') diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 6bdba2468..d2e35362f 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -23,8 +23,7 @@ namespace Service::AM::Applets { -AppletDataBroker::AppletDataBroker() { - auto& kernel = Core::System::GetInstance().Kernel(); +AppletDataBroker::AppletDataBroker(Kernel::KernelCore& kernel) { state_changed_event = Kernel::WritableEvent::CreateEventPair( kernel, Kernel::ResetType::Manual, "ILibraryAppletAccessor:StateChangedEvent"); pop_out_data_event = Kernel::WritableEvent::CreateEventPair( @@ -121,7 +120,7 @@ Kernel::SharedPtr AppletDataBroker::GetStateChangedEvent( return state_changed_event.readable; } -Applet::Applet() = default; +Applet::Applet(Kernel::KernelCore& kernel_) : broker{kernel_} {} Applet::~Applet() = default; @@ -154,7 +153,7 @@ AppletFrontendSet::AppletFrontendSet(AppletFrontendSet&&) noexcept = default; AppletFrontendSet& AppletFrontendSet::operator=(AppletFrontendSet&&) noexcept = default; -AppletManager::AppletManager() = default; +AppletManager::AppletManager(Core::System& system_) : system{system_} {} AppletManager::~AppletManager() = default; @@ -216,28 +215,28 @@ void AppletManager::ClearAll() { frontend = {}; } -std::shared_ptr AppletManager::GetApplet(AppletId id, u64 current_process_title_id) const { +std::shared_ptr AppletManager::GetApplet(AppletId id) const { switch (id) { case AppletId::Auth: - return std::make_shared(*frontend.parental_controls); + return std::make_shared(system, *frontend.parental_controls); case AppletId::Error: - return std::make_shared(*frontend.error); + return std::make_shared(system, *frontend.error); case AppletId::ProfileSelect: - return std::make_shared(*frontend.profile_select); + return std::make_shared(system, *frontend.profile_select); case AppletId::SoftwareKeyboard: - return std::make_shared(*frontend.software_keyboard); + return std::make_shared(system, *frontend.software_keyboard); case AppletId::PhotoViewer: - return std::make_shared(*frontend.photo_viewer); + return std::make_shared(system, *frontend.photo_viewer); case AppletId::LibAppletShop: - return std::make_shared(*frontend.web_browser, current_process_title_id, + return std::make_shared(system, *frontend.web_browser, frontend.e_commerce.get()); case AppletId::LibAppletOff: - return std::make_shared(*frontend.web_browser, current_process_title_id); + return std::make_shared(system, *frontend.web_browser); default: UNIMPLEMENTED_MSG( "No backend implementation exists for applet_id={:02X}! Falling back to stub applet.", static_cast(id)); - return std::make_shared(id); + return std::make_shared(system, id); } } -- cgit v1.2.3