service/am: Implement friend invitation storage channel

Implements TryPopFromFriendInvitationStorageChannel to properly handle
friend invitation data storage and retrieval. This includes:

- Add ResultNoData error code to am_results.h
- Add friend_invitation_storage_channel storage queue to Applet struct
- Implement proper data handling in TryPopFromFriendInvitationStorageChannel

The implementation now properly manages a queue of friend invitation data
and returns appropriate results based on data availability.
This commit is contained in:
Zephyron 2025-01-06 16:57:45 +10:00
parent 60cb826e93
commit 83393a6c6b
No known key found for this signature in database
GPG key ID: 8DA271B6A74353F1
3 changed files with 20 additions and 2 deletions

View file

@ -13,5 +13,6 @@ constexpr Result ResultLibraryAppletTerminated{ErrorModule::AM, 22};
constexpr Result ResultInvalidOffset{ErrorModule::AM, 503}; constexpr Result ResultInvalidOffset{ErrorModule::AM, 503};
constexpr Result ResultInvalidStorageType{ErrorModule::AM, 511}; constexpr Result ResultInvalidStorageType{ErrorModule::AM, 511};
constexpr Result ResultFatalSectionCountImbalance{ErrorModule::AM, 512}; constexpr Result ResultFatalSectionCountImbalance{ErrorModule::AM, 512};
constexpr Result ResultNoData{ErrorModule::AM, 2};
} // namespace Service::AM } // namespace Service::AM

View file

@ -133,6 +133,9 @@ struct Applet {
void UpdateSuspensionStateLocked(bool force_message); void UpdateSuspensionStateLocked(bool force_message);
void SetInteractibleLocked(bool interactible); void SetInteractibleLocked(bool interactible);
void OnProcessTerminatedLocked(); void OnProcessTerminatedLocked();
// Storage channels
std::deque<std::vector<u8>> friend_invitation_storage_channel;
}; };
} // namespace Service::AM } // namespace Service::AM

View file

@ -456,8 +456,22 @@ Result IApplicationFunctions::GetFriendInvitationStorageChannelEvent(
Result IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( Result IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
Out<SharedPointer<IStorage>> out_storage) { Out<SharedPointer<IStorage>> out_storage) {
LOG_INFO(Service_AM, "(STUBBED) called"); LOG_DEBUG(Service_AM, "called");
R_THROW(AM::ResultNoDataInChannel);
std::scoped_lock lock{m_applet->lock};
// Check if there's any data in the friend invitation storage channel
if (m_applet->friend_invitation_storage_channel.empty()) {
R_THROW(AM::ResultNoData);
}
// Pop the most recent data
std::vector<u8> data = std::move(m_applet->friend_invitation_storage_channel.front());
m_applet->friend_invitation_storage_channel.pop_front();
// Create IStorage containing the data
*out_storage = std::make_shared<IStorage>(system, std::move(data));
R_SUCCEED();
} }
Result IApplicationFunctions::GetNotificationStorageChannelEvent( Result IApplicationFunctions::GetNotificationStorageChannelEvent(