From ba2c917842ffcefe3bf7a9799cac6cefc8c284bf Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 17 Apr 2021 08:50:49 -0400 Subject: [PATCH] applets: Make the applet mode a protected property of Applet --- src/core/hle/service/am/applets/applets.cpp | 3 ++- src/core/hle/service/am/applets/applets.h | 15 ++++++++++----- src/core/hle/service/am/applets/controller.cpp | 2 +- src/core/hle/service/am/applets/controller.h | 1 - src/core/hle/service/am/applets/error.cpp | 2 +- src/core/hle/service/am/applets/error.h | 1 - .../hle/service/am/applets/general_backend.cpp | 6 +++--- src/core/hle/service/am/applets/general_backend.h | 3 --- .../hle/service/am/applets/profile_select.cpp | 2 +- src/core/hle/service/am/applets/profile_select.h | 1 - .../hle/service/am/applets/software_keyboard.cpp | 2 +- .../hle/service/am/applets/software_keyboard.h | 1 - src/core/hle/service/am/applets/web_browser.cpp | 2 +- src/core/hle/service/am/applets/web_browser.h | 1 - 14 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 5ddad851a..6a15947cf 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -128,7 +128,8 @@ std::shared_ptr AppletDataBroker::GetStateChangedEvent() return state_changed_event->GetReadableEvent(); } -Applet::Applet(Kernel::KernelCore& kernel_) : broker{kernel_} {} +Applet::Applet(Kernel::KernelCore& kernel_, LibraryAppletMode applet_mode_) + : broker{kernel_}, applet_mode{applet_mode_} {} Applet::~Applet() = default; diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 26b482015..49a561813 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -127,7 +127,7 @@ private: class Applet { public: - explicit Applet(Kernel::KernelCore& kernel_); + explicit Applet(Kernel::KernelCore& kernel_, LibraryAppletMode applet_mode_); virtual ~Applet(); virtual void Initialize(); @@ -137,10 +137,6 @@ public: virtual void ExecuteInteractive() = 0; virtual void Execute() = 0; - bool IsInitialized() const { - return initialized; - } - AppletDataBroker& GetBroker() { return broker; } @@ -149,6 +145,14 @@ public: return broker; } + LibraryAppletMode GetLibraryAppletMode() const { + return applet_mode; + } + + bool IsInitialized() const { + return initialized; + } + protected: struct CommonArguments { u32_le arguments_version; @@ -162,6 +166,7 @@ protected: CommonArguments common_args{}; AppletDataBroker broker; + LibraryAppletMode applet_mode; bool initialized = false; }; diff --git a/src/core/hle/service/am/applets/controller.cpp b/src/core/hle/service/am/applets/controller.cpp index a33f05f97..baaac6446 100644 --- a/src/core/hle/service/am/applets/controller.cpp +++ b/src/core/hle/service/am/applets/controller.cpp @@ -47,7 +47,7 @@ static Core::Frontend::ControllerParameters ConvertToFrontendParameters( Controller::Controller(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::ControllerApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} Controller::~Controller() = default; diff --git a/src/core/hle/service/am/applets/controller.h b/src/core/hle/service/am/applets/controller.h index 07cb92bf9..2d4dae0bd 100644 --- a/src/core/hle/service/am/applets/controller.h +++ b/src/core/hle/service/am/applets/controller.h @@ -120,7 +120,6 @@ public: void ConfigurationComplete(); private: - LibraryAppletMode applet_mode; const Core::Frontend::ControllerApplet& frontend; Core::System& system; diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index a9f0a9c95..28d7f8e24 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp @@ -88,7 +88,7 @@ ResultCode Decode64BitError(u64 error) { Error::Error(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::ErrorApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} Error::~Error() = default; diff --git a/src/core/hle/service/am/applets/error.h b/src/core/hle/service/am/applets/error.h index a3e520cd4..e606d12ce 100644 --- a/src/core/hle/service/am/applets/error.h +++ b/src/core/hle/service/am/applets/error.h @@ -41,7 +41,6 @@ public: private: union ErrorArguments; - LibraryAppletMode applet_mode; const Core::Frontend::ErrorApplet& frontend; ResultCode error_code = RESULT_SUCCESS; ErrorAppletMode mode = ErrorAppletMode::ShowError; diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index 71016cce7..6a37c9e14 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp @@ -39,7 +39,7 @@ static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) Auth::Auth(Core::System& system_, LibraryAppletMode applet_mode_, Core::Frontend::ParentalControlsApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} Auth::~Auth() = default; @@ -155,7 +155,7 @@ void Auth::AuthFinished(bool is_successful) { PhotoViewer::PhotoViewer(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::PhotoViewerApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} PhotoViewer::~PhotoViewer() = default; @@ -205,7 +205,7 @@ void PhotoViewer::ViewFinished() { } StubApplet::StubApplet(Core::System& system_, AppletId id_, LibraryAppletMode applet_mode_) - : Applet{system_.Kernel()}, id{id_}, applet_mode{applet_mode_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, id{id_}, system{system_} {} StubApplet::~StubApplet() = default; diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h index d9e6d4384..7496ded88 100644 --- a/src/core/hle/service/am/applets/general_backend.h +++ b/src/core/hle/service/am/applets/general_backend.h @@ -33,7 +33,6 @@ public: void AuthFinished(bool is_successful = true); private: - LibraryAppletMode applet_mode; Core::Frontend::ParentalControlsApplet& frontend; Core::System& system; bool complete = false; @@ -65,7 +64,6 @@ public: void ViewFinished(); private: - LibraryAppletMode applet_mode; const Core::Frontend::PhotoViewerApplet& frontend; bool complete = false; PhotoViewerAppletMode mode = PhotoViewerAppletMode::CurrentApp; @@ -86,7 +84,6 @@ public: private: AppletId id; - LibraryAppletMode applet_mode; Core::System& system; }; diff --git a/src/core/hle/service/am/applets/profile_select.cpp b/src/core/hle/service/am/applets/profile_select.cpp index ab8b6fcc5..b691406b4 100644 --- a/src/core/hle/service/am/applets/profile_select.cpp +++ b/src/core/hle/service/am/applets/profile_select.cpp @@ -17,7 +17,7 @@ constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::ProfileSelectApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} ProfileSelect::~ProfileSelect() = default; diff --git a/src/core/hle/service/am/applets/profile_select.h b/src/core/hle/service/am/applets/profile_select.h index 90f054030..f0dd6c1f3 100644 --- a/src/core/hle/service/am/applets/profile_select.h +++ b/src/core/hle/service/am/applets/profile_select.h @@ -47,7 +47,6 @@ public: void SelectionComplete(std::optional uuid); private: - LibraryAppletMode applet_mode; const Core::Frontend::ProfileSelectApplet& frontend; UserSelectionConfig config; diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index c3a05de9c..ed5f8162d 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp @@ -44,7 +44,7 @@ void SetReplyBase(std::vector& reply, SwkbdState state, SwkbdReplyType reply SoftwareKeyboard::SoftwareKeyboard(Core::System& system_, LibraryAppletMode applet_mode_, Core::Frontend::SoftwareKeyboardApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend{frontend_}, system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend{frontend_}, system{system_} {} SoftwareKeyboard::~SoftwareKeyboard() = default; diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 85aeb4eb1..7c67b7574 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h @@ -136,7 +136,6 @@ private: void ReplyChangedStringUtf8V2(); void ReplyMovedCursorUtf8V2(); - LibraryAppletMode applet_mode; Core::Frontend::SoftwareKeyboardApplet& frontend; Core::System& system; diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index b28b849bc..0db9592ec 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp @@ -210,7 +210,7 @@ void ExtractSharedFonts(Core::System& system) { WebBrowser::WebBrowser(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::WebBrowserApplet& frontend_) - : Applet{system_.Kernel()}, applet_mode{applet_mode_}, frontend(frontend_), system{system_} {} + : Applet{system_.Kernel(), applet_mode_}, frontend(frontend_), system{system_} {} WebBrowser::~WebBrowser() = default; diff --git a/src/core/hle/service/am/applets/web_browser.h b/src/core/hle/service/am/applets/web_browser.h index 5eafbae7b..21fd910c2 100644 --- a/src/core/hle/service/am/applets/web_browser.h +++ b/src/core/hle/service/am/applets/web_browser.h @@ -64,7 +64,6 @@ private: void ExecuteWifi(); void ExecuteLobby(); - LibraryAppletMode applet_mode; const Core::Frontend::WebBrowserApplet& frontend; bool complete{false};