Skip to content

Commit

Permalink
Stub INotificationService
Browse files Browse the repository at this point in the history
  • Loading branch information
bylaws authored and PixelyIon committed Aug 15, 2020
1 parent 9d90cd8 commit cf60869
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/cpp/skyline/services/base_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ namespace skyline::service {
account_IProfile,
friends_IServiceCreator,
friends_IFriendService,
friends_INotificationService,
nfp_IUserManager,
nfp_IUser,
nifm_IStaticService,
nifm_IGeneralService,
nifm_IRequest,
socket_IClient,
ssl_ISslService,
ssl_ISslContext,
prepo_IPrepoService
};

Expand Down Expand Up @@ -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<u32>(request.payload->value));
return;
}

try {
function(session, request, response);
} catch (std::exception &e) {
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/cpp/skyline/services/friends/INotificationService.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)

#include <kernel/types/KProcess.h>
#include "INotificationService.h"

namespace skyline::service::friends {
INotificationService::INotificationService(const DeviceState &state, ServiceManager &manager) : notificationEvent(std::make_shared<type::KEvent>(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);
}
}
26 changes: 26 additions & 0 deletions app/src/main/cpp/skyline/services/friends/INotificationService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)

#pragma once

#include <kernel/types/KEvent.h>
#include <services/base_service.h>
#include <services/serviceman.h>

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<kernel::type::KEvent> 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);
};
}

0 comments on commit cf60869

Please sign in to comment.