diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 1794fc7c..156185ab 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -115,6 +115,8 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/lm/ILogger.cpp ${source_DIR}/skyline/services/account/IAccountServiceForApplication.cpp ${source_DIR}/skyline/services/account/IManagerForApplication.cpp + ${source_DIR}/skyline/services/friends/IServiceCreator.cpp + ${source_DIR}/skyline/services/friends/IFriendService.cpp ${source_DIR}/skyline/vfs/partition_filesystem.cpp ${source_DIR}/skyline/vfs/rom_filesystem.cpp ${source_DIR}/skyline/vfs/os_backing.cpp diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index a3ac90ae..8120d3db 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -71,6 +71,8 @@ namespace skyline::service { lm_ILogger, account_IAccountServiceForApplication, account_IManagerForApplication, + friends_IServiceCreator, + friends_IFriendService, }; /** @@ -105,6 +107,7 @@ namespace skyline::service { {"pctl:r", Service::pctl_IParentalControlServiceFactory}, {"lm", Service::lm_ILogService}, {"acc:u0", Service::account_IAccountServiceForApplication}, + {"friend:u", Service::friends_IServiceCreator}, }; class ServiceManager; diff --git a/app/src/main/cpp/skyline/services/friends/IFriendService.cpp b/app/src/main/cpp/skyline/services/friends/IFriendService.cpp new file mode 100644 index 00000000..d8d51208 --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/IFriendService.cpp @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IFriendService.h" + +namespace skyline::service::friends { + IFriendService::IFriendService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::friends_IFriendService, "friends:IFriendService", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/friends/IFriendService.h b/app/src/main/cpp/skyline/services/friends/IFriendService.h new file mode 100644 index 00000000..12c336b9 --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/IFriendService.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include +#include + +namespace skyline::service::friends { + /** + * @brief IFriendService is used by applications to access information about a user's friends (https://switchbrew.org/wiki/Friend_services#IFriendService) + */ + class IFriendService : public BaseService { + public: + IFriendService(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/friends/IServiceCreator.cpp b/app/src/main/cpp/skyline/services/friends/IServiceCreator.cpp new file mode 100644 index 00000000..79bd4839 --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/IServiceCreator.cpp @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IFriendService.h" +#include "IServiceCreator.h" + +namespace skyline::service::friends { + IServiceCreator::IServiceCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::friends_IServiceCreator, "friends:IServiceCreator", { + {0x0, SFUNC(IServiceCreator::CreateFriendService)} + }) {} + + void IServiceCreator::CreateFriendService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IFriendService), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/friends/IServiceCreator.h b/app/src/main/cpp/skyline/services/friends/IServiceCreator.h new file mode 100644 index 00000000..ad4f765b --- /dev/null +++ b/app/src/main/cpp/skyline/services/friends/IServiceCreator.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include +#include + +namespace skyline::service::friends { + /** + * @brief IServiceCreator or friend:u is used by applications to open an IFriendService instance for accessing user friend info (https://switchbrew.org/wiki/Friend_services#friend:u.2C_friend:v.2C_friend:m.2C_friend:s.2C_friend:a) + */ + class IServiceCreator : public BaseService { + public: + IServiceCreator(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This opens an IFriendService that can be used by applications to access user friend info + */ + void CreateFriendService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index a931a66b..d8c3ca81 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -21,6 +21,7 @@ #include "pctl/IParentalControlServiceFactory.h" #include "lm/ILogService.h" #include "account/IAccountServiceForApplication.h" +#include "friends/IServiceCreator.h" #include "serviceman.h" namespace skyline::service { @@ -90,6 +91,9 @@ namespace skyline::service { case Service::account_IAccountServiceForApplication: serviceObj = std::make_shared(state, *this); break; + case Service::friends_IServiceCreator: + serviceObj = std::make_shared(state, *this); + break; default: throw exception("CreateService called on missing object, type: {}", serviceType); }