diff --git a/src/core/hle/service/news/news.cpp b/src/core/hle/service/news/news.cpp index 8b70ec45b..51304b013 100644 --- a/src/core/hle/service/news/news.cpp +++ b/src/core/hle/service/news/news.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include "common/logging/log.h" -#include "core/hle/service/news/news.h" #include "core/hle/service/news/news_s.h" #include "core/hle/service/news/news_u.h" #include "core/hle/service/service.h" @@ -11,15 +10,11 @@ namespace Service { namespace NEWS { -void Init() { - using namespace Kernel; - - AddService(new NEWS_S_Interface); - AddService(new NEWS_U_Interface); +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared()->InstallAsService(service_manager); + std::make_shared()->InstallAsService(service_manager); } -void Shutdown() {} - } // namespace NEWS } // namespace Service diff --git a/src/core/hle/service/news/news.h b/src/core/hle/service/news/news.h index 46a3ffcb5..35308369e 100644 --- a/src/core/hle/service/news/news.h +++ b/src/core/hle/service/news/news.h @@ -7,11 +7,7 @@ namespace Service { namespace NEWS { -/// Initialize NEWS service(s) -void Init(); - -/// Shutdown NEWS service(s) -void Shutdown(); +void InstallInterfaces(SM::ServiceManager& service_manager); } // namespace NEWS } // namespace Service diff --git a/src/core/hle/service/news/news_s.cpp b/src/core/hle/service/news/news_s.cpp index 64f8d1b79..1949a22f0 100644 --- a/src/core/hle/service/news/news_s.cpp +++ b/src/core/hle/service/news/news_s.cpp @@ -3,23 +3,13 @@ // Refer to the license.txt file included. #include "core/hle/ipc_helpers.h" -#include "core/hle/service/news/news.h" #include "core/hle/service/news/news_s.h" namespace Service { namespace NEWS { -/** - * GetTotalNotifications service function. - * Inputs: - * 0 : 0x00050000 - * Outputs: - * 0 : 0x00050080 - * 1 : Result of function, 0 on success, otherwise error code - * 2 : Number of notifications - */ -static void GetTotalNotifications(Service::Interface* self) { - IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 0, 0); +void NEWS_S::GetTotalNotifications(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x5, 0, 0); LOG_WARNING(Service, "(STUBBED) called"); @@ -29,24 +19,23 @@ static void GetTotalNotifications(Service::Interface* self) { rb.Push(0); } -const Interface::FunctionInfo FunctionTable[] = { - {0x000100C6, nullptr, "AddNotification"}, - {0x00050000, GetTotalNotifications, "GetTotalNotifications"}, - {0x00060042, nullptr, "SetNewsDBHeader"}, - {0x00070082, nullptr, "SetNotificationHeader"}, - {0x00080082, nullptr, "SetNotificationMessage"}, - {0x00090082, nullptr, "SetNotificationImage"}, - {0x000A0042, nullptr, "GetNewsDBHeader"}, - {0x000B0082, nullptr, "GetNotificationHeader"}, - {0x000C0082, nullptr, "GetNotificationMessage"}, - {0x000D0082, nullptr, "GetNotificationImage"}, - {0x000E0040, nullptr, "SetInfoLEDPattern"}, - {0x00120082, nullptr, "GetNotificationHeaderOther"}, - {0x00130000, nullptr, "WriteNewsDBSavedata"}, -}; - -NEWS_S_Interface::NEWS_S_Interface() { - Register(FunctionTable); +NEWS_S::NEWS_S() : ServiceFramework("news:s", 2) { + const FunctionInfo functions[] = { + {0x000100C6, nullptr, "AddNotification"}, + {0x00050000, &NEWS_S::GetTotalNotifications, "GetTotalNotifications"}, + {0x00060042, nullptr, "SetNewsDBHeader"}, + {0x00070082, nullptr, "SetNotificationHeader"}, + {0x00080082, nullptr, "SetNotificationMessage"}, + {0x00090082, nullptr, "SetNotificationImage"}, + {0x000A0042, nullptr, "GetNewsDBHeader"}, + {0x000B0082, nullptr, "GetNotificationHeader"}, + {0x000C0082, nullptr, "GetNotificationMessage"}, + {0x000D0082, nullptr, "GetNotificationImage"}, + {0x000E0040, nullptr, "SetInfoLEDPattern"}, + {0x00120082, nullptr, "GetNotificationHeaderOther"}, + {0x00130000, nullptr, "WriteNewsDBSavedata"}, + }; + RegisterHandlers(functions); } } // namespace NEWS diff --git a/src/core/hle/service/news/news_s.h b/src/core/hle/service/news/news_s.h index f58b969a8..890aa1f01 100644 --- a/src/core/hle/service/news/news_s.h +++ b/src/core/hle/service/news/news_s.h @@ -4,18 +4,27 @@ #pragma once +#include #include "core/hle/service/service.h" namespace Service { namespace NEWS { -class NEWS_S_Interface : public Service::Interface { +class NEWS_S final : public ServiceFramework { public: - NEWS_S_Interface(); + NEWS_S(); - std::string GetPortName() const override { - return "news:s"; - } +private: + /** + * GetTotalNotifications service function. + * Inputs: + * 0 : 0x00050000 + * Outputs: + * 0 : 0x00050080 + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Number of notifications + */ + void GetTotalNotifications(Kernel::HLERequestContext& ctx); }; } // namespace NEWS diff --git a/src/core/hle/service/news/news_u.cpp b/src/core/hle/service/news/news_u.cpp index 19b687144..af8a06e36 100644 --- a/src/core/hle/service/news/news_u.cpp +++ b/src/core/hle/service/news/news_u.cpp @@ -7,12 +7,11 @@ namespace Service { namespace NEWS { -const Interface::FunctionInfo FunctionTable[] = { - {0x000100C8, nullptr, "AddNotification"}, -}; - -NEWS_U_Interface::NEWS_U_Interface() { - Register(FunctionTable); +NEWS_U::NEWS_U() : ServiceFramework("news:u", 1) { + const FunctionInfo functions[] = { + {0x000100C8, nullptr, "AddNotification"}, + }; + RegisterHandlers(functions); } } // namespace NEWS diff --git a/src/core/hle/service/news/news_u.h b/src/core/hle/service/news/news_u.h index 2720053d0..d78648e44 100644 --- a/src/core/hle/service/news/news_u.h +++ b/src/core/hle/service/news/news_u.h @@ -4,18 +4,15 @@ #pragma once +#include #include "core/hle/service/service.h" namespace Service { namespace NEWS { -class NEWS_U_Interface : public Service::Interface { +class NEWS_U final : public ServiceFramework { public: - NEWS_U_Interface(); - - std::string GetPortName() const override { - return "news:u"; - } + NEWS_U(); }; } // namespace NEWS diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 75ae94661..01c9455b4 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -250,7 +250,7 @@ void Init() { IR::InstallInterfaces(*SM::g_service_manager); MVD::Init(); NDM::Init(); - NEWS::Init(); + NEWS::InstallInterfaces(*SM::g_service_manager); NFC::Init(); NIM::InstallInterfaces(*SM::g_service_manager); NWM::Init(); @@ -272,7 +272,6 @@ void Init() { /// Shutdown ServiceManager void Shutdown() { NFC::Shutdown(); - NEWS::Shutdown(); NDM::Shutdown(); FRD::Shutdown(); DLP::Shutdown();