Add an empty friend service implementation

This is used to access a users friends. It is used by Super Mario
Odyssey.
This commit is contained in:
Billy Laws 2020-07-09 14:22:49 +01:00 committed by ◱ PixelyIon
parent ff5dddbd5b
commit 4cf7f9288e
7 changed files with 72 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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", {
}) {}
}

View File

@ -0,0 +1,17 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/base_service.h>
#include <services/serviceman.h>
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);
};
}

View File

@ -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);
}
}

View File

@ -0,0 +1,22 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/base_service.h>
#include <services/serviceman.h>
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);
};
}

View File

@ -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<account::IAccountServiceForApplication>(state, *this);
break;
case Service::friends_IServiceCreator:
serviceObj = std::make_shared<friends::IServiceCreator>(state, *this);
break;
default:
throw exception("CreateService called on missing object, type: {}", serviceType);
}