libnx  v4.8.0
acc.h
Go to the documentation of this file.
1 /**
2  * @file acc.h
3  * @brief Account (acc:*) service IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../sf/service.h"
10 
11 #define ACC_USER_LIST_SIZE 8
12 
13 typedef enum {
14  AccountServiceType_Application = 0, ///< Initializes acc:u0.
15  AccountServiceType_System = 1, ///< Initializes acc:u1.
16  AccountServiceType_Administrator = 2, ///< Initializes acc:su.
18 
19 /// Profile
20 typedef struct {
21  Service s; ///< IProfile
23 
24 /// Account UserId.
25 typedef struct {
26  u64 uid[2]; ///< UserId. All-zero is invalid / Uid not set. See also \ref accountUidIsValid.
27 } AccountUid;
28 
29 /// UserData
30 typedef struct {
31  u32 unk_x0; ///< Unknown.
32  u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs.
33  u8 iconBackgroundColorID; ///< Profile icon background color ID
34  u8 unk_x9[0x7]; ///< Unknown.
35  u8 miiID[0x10]; ///< Some ID related to the Mii? All zeros when a character icon is used.
36  u8 unk_x20[0x60]; ///< Usually zeros?
38 
39 /// ProfileBase
40 typedef struct {
41  AccountUid uid; ///< \ref AccountUid
42  u64 lastEditTimestamp; ///< POSIX UTC timestamp, for the last account edit.
43  char nickname[0x20]; ///< UTF-8 Nickname.
45 
46 /// NetworkServiceAccountId
47 typedef struct {
48  u64 id; ///< Id.
50 
51 /// Initialize account.
53 
54 /// Exit account.
55 void accountExit(void);
56 
57 /// Gets the Service object for the actual account service session.
59 
60 /// Get the total number of user profiles.
62 
63 /**
64  * @brief Get a list of all userIds. The returned list will never be larger than ACC_USER_LIST_SIZE.
65  * @param uids Pointer to array of userIds.
66  * @param max_uids Maximum number of userIds to return.
67  * @param actual_total The actual total number of userIds found.
68  */
69 Result accountListAllUsers(AccountUid* uids, s32 max_uids, s32 *actual_total);
70 
71 /// Get the userId for the last opened user.
73 
74 /// Get an AccountProfile for the specified userId.
76 
77 /// IsUserRegistrationRequestPermitted
79 
80 /// TrySelectUserWithoutInteraction
81 Result accountTrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required);
82 
83 /// Close the AccountProfile.
85 
86 /// Get \ref AccountUserData and \ref AccountProfileBase for the specified profile, userdata is optional (can be NULL).
88 
89 /// Get the icon image size.
91 
92 /// Load the JPEG profile icon, valid for both Miis and character icons. The output image_size is the same as the one from \ref accountProfileGetImageSize.
93 Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, u32* image_size);
94 
95 /// Gets the userId which was selected by the profile-selector applet (if any), prior to launching the currently running Application.
96 /// This gets the cached PreselectedUser loaded during accountInitialize, when PreselectedUser is available.
98 
99 /**
100  * @brief Checks whether the specified \ref AccountUid is valid/set (non-zero).
101  * @param[in] Uid \ref AccountUid
102  */
104  return Uid->uid[0]!=0 || Uid->uid[1]!=0;
105 }
106 
Result accountProfileLoadImage(AccountProfile *profile, void *buf, size_t len, u32 *image_size)
Load the JPEG profile icon, valid for both Miis and character icons. The output image_size is the sam...
Result accountGetProfile(AccountProfile *out, AccountUid uid)
Get an AccountProfile for the specified userId.
Result accountGetUserCount(s32 *user_count)
Get the total number of user profiles.
Result accountListAllUsers(AccountUid *uids, s32 max_uids, s32 *actual_total)
Get a list of all userIds.
Result accountInitialize(AccountServiceType service_type)
Initialize account.
Result accountTrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required)
TrySelectUserWithoutInteraction.
Result accountGetPreselectedUser(AccountUid *uid)
Gets the userId which was selected by the profile-selector applet (if any), prior to launching the cu...
static bool accountUidIsValid(const AccountUid *Uid)
Checks whether the specified AccountUid is valid/set (non-zero).
Definition: acc.h:103
Result accountProfileGetImageSize(AccountProfile *profile, u32 *image_size)
Get the icon image size.
Result accountProfileGet(AccountProfile *profile, AccountUserData *userdata, AccountProfileBase *profilebase)
Get AccountUserData and AccountProfileBase for the specified profile, userdata is optional (can be NU...
void accountProfileClose(AccountProfile *profile)
Close the AccountProfile.
void accountExit(void)
Exit account.
Service * accountGetServiceSession(void)
Gets the Service object for the actual account service session.
Result accountGetLastOpenedUser(AccountUid *uid)
Get the userId for the last opened user.
Result accountIsUserRegistrationRequestPermitted(bool *out)
IsUserRegistrationRequestPermitted.
AccountServiceType
Definition: acc.h:13
@ AccountServiceType_Application
Initializes acc:u0.
Definition: acc.h:14
@ AccountServiceType_Administrator
Initializes acc:su.
Definition: acc.h:16
@ AccountServiceType_System
Initializes acc:u1.
Definition: acc.h:15
NetworkServiceAccountId.
Definition: acc.h:47
u64 id
Id.
Definition: acc.h:48
ProfileBase.
Definition: acc.h:40
u64 lastEditTimestamp
POSIX UTC timestamp, for the last account edit.
Definition: acc.h:42
AccountUid uid
AccountUid
Definition: acc.h:41
Profile.
Definition: acc.h:20
Service s
IProfile.
Definition: acc.h:21
Account UserId.
Definition: acc.h:25
u64 uid[2]
UserId. All-zero is invalid / Uid not set. See also accountUidIsValid.
Definition: acc.h:26
UserData.
Definition: acc.h:30
u32 iconID
Icon ID. 0 = Mii, the rest are character icon IDs.
Definition: acc.h:32
u32 unk_x0
Unknown.
Definition: acc.h:31
u8 iconBackgroundColorID
Profile icon background color ID.
Definition: acc.h:33
Service object structure.
Definition: service.h:14
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
u32 Result
Function error code result type.
Definition: types.h:44
#define NX_CONSTEXPR
Flags a function as constexpr in C++14 and above; or as (always) inline otherwise.
Definition: types.h:92
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21