mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 02:22:15 +02:00
Added accountGetUserCount and accountListAllUsers
This commit is contained in:
parent
c597631c4d
commit
2330ebce99
@ -8,6 +8,8 @@
|
||||
#include "../types.h"
|
||||
#include "sm.h"
|
||||
|
||||
#define ACC_USER_LIST_SIZE 8
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
} AccountProfile;
|
||||
@ -33,6 +35,15 @@ Result accountInitialize(void);
|
||||
void accountExit(void);
|
||||
Service* accountGetService(void);
|
||||
|
||||
/// Get the total number of user profiles
|
||||
Result accountGetUserCount(s32* user_count);
|
||||
|
||||
/**
|
||||
* @brief Get a list of all user IDs
|
||||
* @param userIDs Pointer to array of user IDs, array must be exactly size 8
|
||||
*/
|
||||
Result accountListAllUsers(u128* userIDs);
|
||||
|
||||
/// Get the userID for the currently active user. The output userID is only valid when the output account_selected==1, otherwise no user is currently selected.
|
||||
/// An user is only selected when the user-account selection applet was used to select an user at least once before.
|
||||
Result accountGetActiveUser(u128 *userID, bool *account_selected);
|
||||
|
@ -33,6 +33,81 @@ Service* accountGetService(void) {
|
||||
return &g_accSrv;
|
||||
}
|
||||
|
||||
Result accountGetUserCount(s32* user_count)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_accSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 user_count;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*user_count = resp->user_count;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result accountListAllUsers(u128* userIDs)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
Result rc=0;
|
||||
|
||||
size_t bufsize = ACC_USER_LIST_SIZE * sizeof(u128);
|
||||
|
||||
ipcAddRecvStatic(&c, userIDs, bufsize, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
|
||||
rc = serviceIpcDispatch(&g_accSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result accountGetActiveUser(u128 *userID, bool *account_selected)
|
||||
{
|
||||
IpcCommand c;
|
||||
|
Loading…
Reference in New Issue
Block a user