forked from DrHacknik/skyline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/cpp/skyline/services/friends/INotificationService.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
app/src/main/cpp/skyline/services/friends/INotificationService.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
} |