summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-01-06 16:57:45 +1000
committerMike Lothian <mike@fireburn.co.uk>2025-05-11 12:17:03 +0100
commit2e739c8692b53fb4391b57993108056cc8f5e5c6 (patch)
treec33848ef17dbf004f8689cedeb056f64f5cf099d
parentea4ff742ce7210e7b01d371025b7cd81d1dc9e7c (diff)
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.
-rw-r--r--src/core/hle/service/am/am_results.h1
-rw-r--r--src/core/hle/service/am/applet.h3
-rw-r--r--src/core/hle/service/am/service/application_functions.cpp18
3 files changed, 20 insertions, 2 deletions
diff --git a/src/core/hle/service/am/am_results.h b/src/core/hle/service/am/am_results.h
index 44846aa2e..ff59d3d87 100644
--- a/src/core/hle/service/am/am_results.h
+++ b/src/core/hle/service/am/am_results.h
@@ -13,5 +13,6 @@ constexpr Result ResultLibraryAppletTerminated{ErrorModule::AM, 22};
constexpr Result ResultInvalidOffset{ErrorModule::AM, 503};
constexpr Result ResultInvalidStorageType{ErrorModule::AM, 511};
constexpr Result ResultFatalSectionCountImbalance{ErrorModule::AM, 512};
+constexpr Result ResultNoData{ErrorModule::AM, 2};
} // namespace Service::AM
diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.h
index 571904fab..6e9fd67e7 100644
--- a/src/core/hle/service/am/applet.h
+++ b/src/core/hle/service/am/applet.h
@@ -133,6 +133,9 @@ struct Applet {
void UpdateSuspensionStateLocked(bool force_message);
void SetInteractibleLocked(bool interactible);
void OnProcessTerminatedLocked();
+
+ // Storage channels
+ std::deque<std::vector<u8>> friend_invitation_storage_channel;
};
} // namespace Service::AM
diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp
index 3bab5ac5f..6fcda9165 100644
--- a/src/core/hle/service/am/service/application_functions.cpp
+++ b/src/core/hle/service/am/service/application_functions.cpp
@@ -456,8 +456,22 @@ Result IApplicationFunctions::GetFriendInvitationStorageChannelEvent(
Result IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
Out<SharedPointer<IStorage>> out_storage) {
- LOG_INFO(Service_AM, "(STUBBED) called");
- R_THROW(AM::ResultNoDataInChannel);
+ LOG_DEBUG(Service_AM, "called");
+
+ 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(