summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liamwhite2022-12-01 22:14:43 -0500
committerGravatar GitHub2022-12-01 22:14:43 -0500
commitd8bd52c6f10f6fcc7629063d77c83671bd99f2cd (patch)
treee910d476595d2b33267f073ae2a38bc96f4c52aa /src
parentMerge pull request #9367 from lat9nq/occam-ffmpeg (diff)
parentservice: nifm: Update stubs for Submit/GetRequestState/GetResult (diff)
downloadyuzu-d8bd52c6f10f6fcc7629063d77c83671bd99f2cd.tar.gz
yuzu-d8bd52c6f10f6fcc7629063d77c83671bd99f2cd.tar.xz
yuzu-d8bd52c6f10f6fcc7629063d77c83671bd99f2cd.zip
Merge pull request #9348 from Morph1984/when-the-network-is-down
service: nifm: Update stubs for Submit/GetRequestState/GetResult
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nifm/nifm.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index e3ef06481..4fa9f51a6 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -129,6 +129,9 @@ static_assert(sizeof(NifmNetworkProfileData) == 0x18E,
129 "NifmNetworkProfileData has incorrect size."); 129 "NifmNetworkProfileData has incorrect size.");
130#pragma pack(pop) 130#pragma pack(pop)
131 131
132constexpr Result ResultPendingConnection{ErrorModule::NIFM, 111};
133constexpr Result ResultNetworkCommunicationDisabled{ErrorModule::NIFM, 1111};
134
132class IScanRequest final : public ServiceFramework<IScanRequest> { 135class IScanRequest final : public ServiceFramework<IScanRequest> {
133public: 136public:
134 explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} { 137 explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} {
@@ -192,6 +195,10 @@ private:
192 void Submit(Kernel::HLERequestContext& ctx) { 195 void Submit(Kernel::HLERequestContext& ctx) {
193 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 196 LOG_WARNING(Service_NIFM, "(STUBBED) called");
194 197
198 if (state == RequestState::NotSubmitted) {
199 UpdateState(RequestState::Pending);
200 }
201
195 IPC::ResponseBuilder rb{ctx, 2}; 202 IPC::ResponseBuilder rb{ctx, 2};
196 rb.Push(ResultSuccess); 203 rb.Push(ResultSuccess);
197 } 204 }
@@ -201,19 +208,32 @@ private:
201 208
202 IPC::ResponseBuilder rb{ctx, 3}; 209 IPC::ResponseBuilder rb{ctx, 3};
203 rb.Push(ResultSuccess); 210 rb.Push(ResultSuccess);
204 211 rb.PushEnum(state);
205 if (Network::GetHostIPv4Address().has_value()) {
206 rb.PushEnum(RequestState::Connected);
207 } else {
208 rb.PushEnum(RequestState::NotSubmitted);
209 }
210 } 212 }
211 213
212 void GetResult(Kernel::HLERequestContext& ctx) { 214 void GetResult(Kernel::HLERequestContext& ctx) {
213 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 215 LOG_WARNING(Service_NIFM, "(STUBBED) called");
214 216
217 const auto result = [this] {
218 const auto has_connection = Network::GetHostIPv4Address().has_value();
219 switch (state) {
220 case RequestState::NotSubmitted:
221 return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
222 case RequestState::Pending:
223 if (has_connection) {
224 UpdateState(RequestState::Connected);
225 } else {
226 UpdateState(RequestState::Error);
227 }
228 return ResultPendingConnection;
229 case RequestState::Connected:
230 default:
231 return ResultSuccess;
232 }
233 }();
234
215 IPC::ResponseBuilder rb{ctx, 2}; 235 IPC::ResponseBuilder rb{ctx, 2};
216 rb.Push(ResultSuccess); 236 rb.Push(result);
217 } 237 }
218 238
219 void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) { 239 void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) {
@@ -252,8 +272,15 @@ private:
252 rb.Push<u32>(0); 272 rb.Push<u32>(0);
253 } 273 }
254 274
275 void UpdateState(RequestState new_state) {
276 state = new_state;
277 event1->Signal();
278 }
279
255 KernelHelpers::ServiceContext service_context; 280 KernelHelpers::ServiceContext service_context;
256 281
282 RequestState state;
283
257 Kernel::KEvent* event1; 284 Kernel::KEvent* event1;
258 Kernel::KEvent* event2; 285 Kernel::KEvent* event2;
259}; 286};