libctru  v1.6.0
frd.h
Go to the documentation of this file.
1 /**
2  * @file frd.h
3  * @brief Friend Services
4  */
5 #pragma once
6 #include <3ds/mii.h>
7 
8 #define FRIEND_SCREEN_NAME_SIZE 0xB ///< 11-byte UTF-16 screen name
9 #define FRIEND_COMMENT_SIZE 0x21 ///< 33-byte UTF-16 comment
10 #define FRIEND_LIST_SIZE 0x64 ///< 100 (Max number of friends)
11 
12 #pragma pack(push, 1)
13 
14 /// Friend key data
15 typedef struct
16 {
17  u32 principalId;
18  u32 padding;
19  u64 localFriendCode;
20 } FriendKey;
21 
22 /// Friend Title data
23 typedef struct
24 {
25  u64 tid;
26  u32 version;
27  u32 unk;
28 } TitleData;
29 
30 /// Friend profile data
31 typedef struct
32 {
33  u8 region; ///< The region code for the hardware.
34  u8 country; ///< Country code.
35  u8 area; ///< Area code.
36  u8 language; ///< Language code.
37  u8 platform; ///< Platform code.
38  u32 padding;
40 
41 /// Game Description structure
42 typedef struct
43 {
44  TitleData data;
45  u16 desc[128];
47 
48 /// Friend Notification Event structure
49 typedef struct
50 {
51  u8 type;
52  u8 padding3[3];
53  u32 padding;
54  FriendKey key;
56 
57 #pragma pack(pop)
58 
59 /// Enum to use with FRD_GetNotificationEvent
60 typedef enum
61 {
62  USER_WENT_ONLINE = 1, ///< Self went online
63  USER_WENT_OFFLINE, ///< Self went offline
64  FRIEND_WENT_ONLINE, ///< Friend Went Online
65  FRIEND_UPDATED_PRESENCE, ///< Friend Presence changed
66  FRIEND_UPDATED_MII, ///< Friend Mii changed
67  FRIEND_UPDATED_PROFILE, ///< Friend Profile changed
68  FRIEND_WENT_OFFLINE, ///< Friend went offline
69  FRIEND_REGISTERED_USER, ///< Friend registered self as friend
70  FRIEND_SENT_INVITATION ///< Friend Sent invitation
72 
73 /// Initializes FRD service.
74 Result frdInit(void);
75 
76 /// Exists FRD.
77 void frdExit(void);
78 
79 /// Get FRD handle.
81 /**
82  * @brief Gets the login status of the current user.
83  * @param state Pointer to write the current user's login status to.
84  */
85 Result FRDU_HasLoggedIn(bool *state);
86 
87 /**
88  * @brief Gets the online status of the current user.
89  * @param state Pointer to write the current user's online status to.
90  */
91 Result FRDU_IsOnline(bool *state);
92 
93 /// Logs out of Nintendo's friend server.
94 Result FRD_Logout(void);
95 
96 /**
97  * @brief Log in to Nintendo's friend server.
98  * @param event Event to signal when Login is done.
99  */
100 Result FRD_Login(Handle event);
101 
102 /**
103  * @brief Gets the current user's friend key.
104  * @param key Pointer to write the current user's friend key to.
105  */
107 
108 /**
109  * @brief Gets the current user's privacy information.
110  * @param isPublicMode Determines whether friends are notified of the current user's online status.
111  * @param isShowGameName Determines whether friends are notified of the application that the current user is running.
112  * @param isShowPlayedGame Determiens whether to display the current user's game history.
113  */
114 Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isShowPlayedGame);
115 
116 /**
117  * @brief Gets the current user's profile information.
118  * @param profile Pointer to write the current user's profile information to.
119  */
121 
122 /**
123  * @brief Gets the current user's screen name.
124  * @param name Pointer to write the current user's screen name to.
125  * @param max_size Max size of the screen name.
126  */
127 Result FRD_GetMyScreenName(char *name, size_t max_size);
128 
129 /**
130  * @brief Gets the current user's Mii data.
131  * @param mii Pointer to write the current user's mii data to.
132  */
134 
135 /**
136  * @brief Gets the current user's playing game.
137  * @param titleId Pointer to write the current user's playing game to.
138  */
140 
141 /**
142  * @brief Gets the current user's favourite game.
143  * @param titleId Pointer to write the title ID of current user's favourite game to.
144  */
146 
147 /**
148  * @brief Gets the current user's comment on their friend profile.
149  * @param comment Pointer to write the current user's comment to.
150  * @param max_size Max size of the comment.
151  */
152 Result FRD_GetMyComment(char *comment, size_t max_size);
153 
154 /**
155  * @brief Gets the current user's friend key list.
156  * @param friendKeyList Pointer to write the friend key list to.
157  * @param num Stores the number of friend keys obtained.
158  * @param offset The index of the friend key to start with.
159  * @param size Size of the friend key list. (FRIEND_LIST_SIZE)
160  */
161 Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 size);
162 
163 /**
164  * @brief Gets the current user's friends' Mii data.
165  * @param miiDataList Pointer to write Mii data to.
166  * @param friendKeyList Pointer to FriendKeys.
167  * @param size Number of Friendkeys.
168  */
169 Result FRD_GetFriendMii(MiiData *miiDataList, const FriendKey *friendKeyList, size_t size);
170 
171 /**
172  * @brief Get the current user's friends' profile data.
173  * @param profile Pointer to write profile data to.
174  * @param friendKeyList Pointer to FriendKeys.
175  * @param size Number of FriendKeys.
176  */
177 Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *friendKeyList, size_t size);
178 
179 /**
180  * @brief Get the current user's friends' playing game.
181  * @param desc Pointer to write Game Description data to.
182  * @param friendKeyList Pointer to FriendKeys,
183  * @param size Number Of FriendKeys.
184  */
185 Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size);
186 
187 /**
188  * @brief Get the current user's friends' favourite game.
189  * @param desc Pointer to write Game Description data to.
190  * @param friendKeyList Pointer to FriendKeys,
191  * @param count Number Of FriendKeys.
192  */
193 Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *friendKeyList, u32 count);
194 
195 /**
196  * @brief Gets whether a friend key is included in the current user's friend list.
197  * @param friendKeyList Pointer to a list of friend keys.
198  * @param isFromList Pointer to a write the friendship status to.
199  */
200 Result FRD_IsInFriendList(FriendKey *friendKeyList, bool *isFromList);
201 
202 /**
203  * @brief Updates the game mode description string.
204  * @param desc Pointer to write the game mode description to.
205  */
206 Result FRD_UpdateGameModeDescription(const char *desc);
207 
208 /**
209  * @brief Event which is signaled when friend login states change.
210  * @param event event which will be signaled.
211  */
213 
214 /**
215  * @brief Get Latest Event Notification
216  * @param event Pointer to write recieved notification event struct to.
217  * @param count Number of events
218  * @param recievedNotifCount Number of notification reccieved.
219  */
220 Result FRD_GetEventNotification(NotificationEvent *event, u32 count, u32 *recievedNotifCount);
221 
222 /**
223  * @brief Returns the friend code using the given principal ID.
224  * @param principalId The principal ID being used.
225  * @param friendCode Pointer to write the friend code to.
226  */
227 Result FRD_PrincipalIdToFriendCode(u32 principalId, u64 *friendCode);
228 
229 /**
230  * @brief Returns the principal ID using the given friend code.
231  * @param friendCode The friend code being used.
232  * @param principalId Pointer to write the principal ID to.
233  */
234 Result FRD_FriendCodeToPrincipalId(u64 friendCode, u32 *principalId);
235 
236 /**
237  * @brief Checks if the friend code is valid.
238  * @param friendCode The friend code being used.
239  * @param isValid Pointer to write the validity of the friend code to.
240  */
241 Result FRD_IsValidFriendCode(u64 friendCode, bool *isValid);
242 
243 /**
244  * @brief Sets the Friend API to use a specific SDK version.
245  * @param sdkVer The SDK version needed to be used.
246  */
248 
249 /**
250  * @brief Add a Friend online.
251  * @param event Event signaled when friend is registered.
252  * @param principalId PrincipalId of the friend to add.
253  */
254 Result FRD_AddFriendOnline(Handle event, u32 principalId);
255 
256 /**
257  * @brief Remove a Friend.
258  * @param principalId PrinipalId of the friend code to remove.
259  * @param localFriendCode LocalFriendCode of the friend code to remove.
260  */
261 Result FRD_RemoveFriend(u32 principalId, u64 localFriendCode);
Friend went offline.
Definition: frd.h:68
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *friendKeyList, size_t size)
Get the current user's friends' profile data.
Result FRD_Login(Handle event)
Log in to Nintendo's friend server.
s32 Result
Function result.
Definition: types.h:42
Friend Notification Event structure.
Definition: frd.h:49
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 size)
Gets the current user's friend key list.
void frdExit(void)
Exists FRD.
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
u8 platform
Platform code.
Definition: frd.h:37
Friend Went Online.
Definition: frd.h:64
Result FRD_IsInFriendList(FriendKey *friendKeyList, bool *isFromList)
Gets whether a friend key is included in the current user's friend list.
Friend Presence changed.
Definition: frd.h:65
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size)
Get the current user's friends' playing game.
u32 Handle
Resource handle.
Definition: types.h:41
Result FRD_GetMyMii(MiiData *mii)
Gets the current user's Mii data.
Result FRD_GetMyComment(char *comment, size_t max_size)
Gets the current user's comment on their friend profile.
Friend registered self as friend.
Definition: frd.h:69
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
NotificationTypes
Enum to use with FRD_GetNotificationEvent.
Definition: frd.h:60
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
Result FRD_IsValidFriendCode(u64 friendCode, bool *isValid)
Checks if the friend code is valid.
u8 region
The region code for the hardware.
Definition: frd.h:33
Result FRD_GetMyPlayingGame(u64 *titleId)
Gets the current user's playing game.
Result FRD_AddFriendOnline(Handle event, u32 principalId)
Add a Friend online.
Shared Mii struct.
Definition: mii.h:12
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Result frdInit(void)
Initializes FRD service.
Result FRD_GetMyProfile(FriendProfile *profile)
Gets the current user's profile information.
Friend Profile changed.
Definition: frd.h:67
Handle * frdGetSessionHandle(void)
Get FRD handle.
Self went offline.
Definition: frd.h:63
Game Description structure.
Definition: frd.h:42
u8 area
Area code.
Definition: frd.h:35
Result FRD_Logout(void)
Logs out of Nintendo's friend server.
Result FRD_SetClientSdkVersion(u32 sdkVer)
Sets the Friend API to use a specific SDK version.
Result FRDU_HasLoggedIn(bool *state)
Gets the login status of the current user.
Shared Mii struct.
Result FRD_GetMyScreenName(char *name, size_t max_size)
Gets the current user's screen name.
Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isShowPlayedGame)
Gets the current user's privacy information.
Result FRD_GetEventNotification(NotificationEvent *event, u32 count, u32 *recievedNotifCount)
Get Latest Event Notification.
Result FRDU_IsOnline(bool *state)
Gets the online status of the current user.
Result FRD_GetMyFavoriteGame(u64 *titleId)
Gets the current user's favourite game.
Self went online.
Definition: frd.h:62
Friend Title data.
Definition: frd.h:23
u8 language
Language code.
Definition: frd.h:36
Result FRD_FriendCodeToPrincipalId(u64 friendCode, u32 *principalId)
Returns the principal ID using the given friend code.
Result FRD_PrincipalIdToFriendCode(u32 principalId, u64 *friendCode)
Returns the friend code using the given principal ID.
Result FRD_GetFriendMii(MiiData *miiDataList, const FriendKey *friendKeyList, size_t size)
Gets the current user's friends' Mii data.
Result FRD_RemoveFriend(u32 principalId, u64 localFriendCode)
Remove a Friend.
Friend Mii changed.
Definition: frd.h:66
Friend profile data.
Definition: frd.h:31
Result FRD_AttachToEventNotification(Handle event)
Event which is signaled when friend login states change.
Result FRD_GetMyFriendKey(FriendKey *key)
Gets the current user's friend key.
Result FRD_UpdateGameModeDescription(const char *desc)
Updates the game mode description string.
Friend Sent invitation.
Definition: frd.h:70
Friend key data.
Definition: frd.h:15
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *friendKeyList, u32 count)
Get the current user's friends' favourite game.
u8 country
Country code.
Definition: frd.h:34