From cf60869fac16b166fe5c56e8977ef2319c6103cc Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 9 Aug 2020 14:54:45 +0100 Subject: [PATCH] Stub INotificationService --- .../main/cpp/skyline/services/base_service.h | 3 +++ .../services/friends/INotificationService.cpp | 18 +++++++++++++ .../services/friends/INotificationService.h | 26 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 app/src/main/cpp/skyline/services/friends/INotificationService.cpp create mode 100644 app/src/main/cpp/skyline/services/friends/INotificationService.h diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index dd354a37..60d6c4eb 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -77,6 +77,7 @@ namespace skyline::service { account_IProfile, friends_IServiceCreator, friends_IFriendService, + friends_INotificationService, nfp_IUserManager, nfp_IUser, nifm_IStaticService, @@ -84,6 +85,7 @@ namespace skyline::service { nifm_IRequest, socket_IClient, ssl_ISslService, + ssl_ISslContext, prepo_IPrepoService }; @@ -164,6 +166,7 @@ namespace skyline::service { state.logger->Warn("Cannot find function in service '{0}' (Type: {1}): 0x{2:X} ({2})", serviceName, serviceType, static_cast(request.payload->value)); return; } + try { function(session, request, response); } catch (std::exception &e) { diff --git a/app/src/main/cpp/skyline/services/friends/INotificationService.cpp b/app/src/main/cpp/skyline/services/friends/INotificationService.cpp new file mode 100644 index 00000000..241a32cc --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/INotificationService.cpp @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include +#include "INotificationService.h" + +namespace skyline::service::friends { + INotificationService::INotificationService(const DeviceState &state, ServiceManager &manager) : notificationEvent(std::make_shared(state)), BaseService(state, manager, Service::friends_INotificationService, "friends:INotificationService", { + {0x0, SFUNC(INotificationService::GetEvent)}, + }) {} + + void INotificationService::GetEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + KHandle handle = state.process->InsertItem(notificationEvent); + state.logger->Debug("Friend Notification Event Handle: 0x{:X}", handle); + + response.copyHandles.push_back(handle); + } +} diff --git a/app/src/main/cpp/skyline/services/friends/INotificationService.h b/app/src/main/cpp/skyline/services/friends/INotificationService.h new file mode 100644 index 00000000..7a545228 --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/INotificationService.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include +#include +#include + +namespace skyline::service::friends { + /** + * @brief INotificationService is used by applications to receive notifications (https://switchbrew.org/wiki/Friend_services#INotificationService) + */ + class INotificationService : public BaseService { + private: + std::shared_ptr notificationEvent; //!< This KEvent is triggered on new notifications + + public: + INotificationService(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns a handle to the notification event + */ + void GetEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +}