Added accountGetUserCount and accountListAllUsers

This commit is contained in:
3Daniel 2018-05-27 22:24:23 +12:00
parent c597631c4d
commit 2330ebce99
2 changed files with 86 additions and 0 deletions

View File

@ -8,6 +8,8 @@
#include "../types.h" #include "../types.h"
#include "sm.h" #include "sm.h"
#define ACC_USER_LIST_SIZE 8
typedef struct { typedef struct {
Service s; Service s;
} AccountProfile; } AccountProfile;
@ -33,6 +35,15 @@ Result accountInitialize(void);
void accountExit(void); void accountExit(void);
Service* accountGetService(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. /// 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. /// 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); Result accountGetActiveUser(u128 *userID, bool *account_selected);

View File

@ -33,6 +33,81 @@ Service* accountGetService(void) {
return &g_accSrv; 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) Result accountGetActiveUser(u128 *userID, bool *account_selected)
{ {
IpcCommand c; IpcCommand c;