diff --git a/nx/include/switch/services/ns.h b/nx/include/switch/services/ns.h index 603419e9..b7123787 100644 --- a/nx/include/switch/services/ns.h +++ b/nx/include/switch/services/ns.h @@ -51,6 +51,11 @@ typedef struct { Service s; ///< IRequestServerStopper } NsRequestServerStopper; +/// ProgressMonitorForDeleteUserSaveDataAll +typedef struct { + Service s; ///< IProgressMonitorForDeleteUserSaveDataAll +} NsProgressMonitorForDeleteUserSaveDataAll; + /// ProgressAsyncResult typedef struct { Service s; ///< IProgressAsyncResult @@ -89,6 +94,11 @@ typedef struct { u8 unk_x11[7]; ///< Unknown. } NsApplicationRecord; +/// ProgressForDeleteUserSaveDataAll +typedef struct { + u8 unk_x0[0x28]; ///< Unknown. +} NsProgressForDeleteUserSaveDataAll; + /// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. typedef struct { u64 application_id; ///< Same as NsApplicationView::application_id. @@ -432,6 +442,13 @@ Result nsGetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *fre */ Result nsRequestUpdateApplication2(AsyncResult *a, u64 application_id); +/** + * @brief DeleteUserSaveDataAll + * @param[in] p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[in] uid \ref AccountUid + */ +Result nsDeleteUserSaveDataAll(NsProgressMonitorForDeleteUserSaveDataAll *p, AccountUid uid); + /** * @brief DeleteUserSystemSaveData * @param[in] uid \ref AccountUid @@ -932,6 +949,45 @@ void nsRequestServerStopperClose(NsRequestServerStopper *r); ///@} +///@name IProgressMonitorForDeleteUserSaveDataAll +///@{ + +/** + * @brief Close a \ref NsProgressMonitorForDeleteUserSaveDataAll. When initialized this will use \ref nsProgressMonitorForDeleteUserSaveDataAllIsFinished, throwing errors on failure / when the operation isn't finished (without closing the object). + * @note Cancelling the operation before it's finished is not supported by \ref NsProgressMonitorForDeleteUserSaveDataAll. + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + */ +Result nsProgressMonitorForDeleteUserSaveDataAllClose(NsProgressMonitorForDeleteUserSaveDataAll *p); + +/** + * @brief GetSystemEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result nsProgressMonitorForDeleteUserSaveDataAllGetSystemEvent(NsProgressMonitorForDeleteUserSaveDataAll *p, Event* out_event); + +/** + * @brief IsFinished + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[out] out Whether the operation finished. + */ +Result nsProgressMonitorForDeleteUserSaveDataAllIsFinished(NsProgressMonitorForDeleteUserSaveDataAll *p, bool *out); + +/** + * @brief GetResult + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + */ +Result nsProgressMonitorForDeleteUserSaveDataAllGetResult(NsProgressMonitorForDeleteUserSaveDataAll *p); + +/** + * @brief GetProgress + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[out] progress Output \ref NsProgressForDeleteUserSaveDataAll. + */ +Result nsProgressMonitorForDeleteUserSaveDataAllGetProgress(NsProgressMonitorForDeleteUserSaveDataAll *p, NsProgressForDeleteUserSaveDataAll *progress); + +///@} + ///@name IProgressAsyncResult ///@{ diff --git a/nx/source/services/ns.c b/nx/source/services/ns.c index cddaa23a..eb9e3950 100644 --- a/nx/source/services/ns.c +++ b/nx/source/services/ns.c @@ -419,6 +419,13 @@ Result nsRequestUpdateApplication2(AsyncResult *a, u64 application_id) { return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 85); } +Result nsDeleteUserSaveDataAll(NsProgressMonitorForDeleteUserSaveDataAll *p, AccountUid uid) { + return serviceDispatchIn(&g_nsAppManSrv, 201, uid, + .out_num_objects = 1, + .out_objects = &p->s, + ); +} + Result nsDeleteUserSystemSaveData(AccountUid uid, u64 system_save_data_id) { const struct { AccountUid uid; @@ -1191,6 +1198,49 @@ void nsRequestServerStopperClose(NsRequestServerStopper *r) { serviceClose(&r->s); } +// IProgressMonitorForDeleteUserSaveDataAll + +Result nsProgressMonitorForDeleteUserSaveDataAllClose(NsProgressMonitorForDeleteUserSaveDataAll *p) { + Result rc=0; + + if (serviceIsActive(&p->s)) { + bool finished=0; + rc = nsProgressMonitorForDeleteUserSaveDataAllIsFinished(p, &finished); + if (R_SUCCEEDED(rc) && !finished) rc = MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen); + } + + if (R_SUCCEEDED(rc)) serviceClose(&p->s); + return rc; +} + +Result nsProgressMonitorForDeleteUserSaveDataAllGetSystemEvent(NsProgressMonitorForDeleteUserSaveDataAll *p, Event* out_event) { + if (!serviceIsActive(&p->s)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _nsCmdGetEvent(&p->s, out_event, false, 0); +} + +Result nsProgressMonitorForDeleteUserSaveDataAllIsFinished(NsProgressMonitorForDeleteUserSaveDataAll *p, bool *out) { + if (!serviceIsActive(&p->s)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _nsCmdNoInOutBool(&p->s, out, 1); +} + +Result nsProgressMonitorForDeleteUserSaveDataAllGetResult(NsProgressMonitorForDeleteUserSaveDataAll *p) { + if (!serviceIsActive(&p->s)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _nsCmdNoIO(&p->s, 2); +} + +Result nsProgressMonitorForDeleteUserSaveDataAllGetProgress(NsProgressMonitorForDeleteUserSaveDataAll *p, NsProgressForDeleteUserSaveDataAll *progress) { + if (!serviceIsActive(&p->s)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return serviceDispatchOut(&p->s, 10, *progress); +} + // IProgressAsyncResult void nsProgressAsyncResultClose(NsProgressAsyncResult *a) {