1 /*---------------------------------------------------------------------------*
2 
3   Copyright (C) Nintendo.  All rights reserved.
4 
5   These coded instructions, statements, and computer programs contain
6   proprietary information of Nintendo of America Inc. and/or Nintendo
7   Company Ltd., and are protected by Federal copyright law.  They may
8   not be disclosed to third parties or copied or duplicated in any form,
9   in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 
13 #ifndef __FP_TYPES_H__
14 #define __FP_TYPES_H__
15 
16 #include <nn/fp/fp_Result.h>
17 #include <nn/fp/fp_Stub.h>
18 
19 /*---------------------------------------------------------------------------*
20 *  Definitions
21  *---------------------------------------------------------------------------*/
22 
23 /*!
24 @ingroup  nn_fp
25 @defgroup nn_fp_const  Friend Presence (FP) Constant Definitions
26 @brief  Constant Definitions in the Friend Presence (FP) Library
27     @{
28 */
29 
30 #define FP_INVALID_PRINCIPAL_ID         (0)                              //!< The principal ID is invalid.
31 
32 #define FP_ACCOUNT_ID_LEN               (16)                             //!< Length of the account ID string.
33 #define FP_ACCOUNT_ID_SIZE              (FP_ACCOUNT_ID_LEN + 1)          //!< Number of elements for the account ID buffer.
34 
35 #define FP_MII_SIZE                     (96)                             //!< Mii character data size.
36 
37 #define FP_MII_SCREEN_NAME_LEN          (10)                             //!< Length of the string for the Mii character's display name.
38 #define FP_MII_SCREEN_NAME_SIZE         (FP_MII_SCREEN_NAME_LEN + 1)     //!< Number of buffer elements for the Mii character's display name. Includes the terminating character.
39 
40 #define FP_MODE_DESCRIPTION_LEN         (127)                            //!< Length of the string for the game mode description.
41 #define FP_MODE_DESCRIPTION_SIZE        (FP_MODE_DESCRIPTION_LEN + 1)    //!< The number of elements in the buffer for the game mode description string. Includes the terminating character.
42 
43 #define FP_REQUEST_MESSAGE_LEN          (63)                             //!< Length of the friend request message string.
44 #define FP_REQUEST_MESSAGE_SIZE         (FP_REQUEST_MESSAGE_LEN + 1)     //!< Number of buffer elements for the friend request message. Includes the terminating character.
45 
46 #define FP_IN_GAME_SCREEN_NAME_LEN      (16)                             //!< String length of the display name of the in-game character.
47 #define FP_IN_GAME_SCREEN_NAME_SIZE     (FP_IN_GAME_SCREEN_NAME_LEN + 1) //!< The number of elements in the buffer for the display name of the in-game character. Includes the terminating character.
48 
49 #define FP_FRIEND_LIST_SIZE             (100)                            //!< The size of the friend list.
50 
51 #define FP_BLACK_LIST_SIZE              (100)                            //!< The size of the blacklist.
52 
53 #define FP_REQUEST_LIST_SIZE            (100)                            //!< The size of the request list.
54 
55 #define FP_RECENT_PLAY_RECORD_LIST_SIZE (100)                            //!< The size of the Player History list.
56 
57 #define FP_REFERENCE_DATA_SIZE          (100)                            //!< Amount of data that can be obtained at one time with the reference functions.
58 
59 #define FP_INVALID_GAME_ID              (0)                              //!< Invalid join-in game ID.
60 
61 #define FP_INVALID_GROUP_ID             (0)                              //!< Invalid join-in group ID.
62 
63 #define FP_APPLICATION_ARG_SIZE         (20)                             //!< The size of the application definition data.
64 
65 //! @}
66 
67 namespace nn { namespace fp {
68 
69 /*---------------------------------------------------------------------------*
70 *  Enumerations
71  *---------------------------------------------------------------------------*/
72 
73 //! @addtogroup  nn_fp_const
74 //! @{
75 
76 /*!
77 @brief  Enumerated type that represents region codes.
78 */
79 enum Region
80 {
81     REGION_INVALID = 0, //!< Invalid region code.
82     REGION_JPN     = 1, //!< Japanese region.
83     REGION_USA     = 2, //!< Americas region.
84     REGION_EUR     = 3, //!< European region.
85     REGION_AUS     = 4, //!< Australian region.
86     REGION_CHN     = 5, //!< Chinese region.
87     REGION_KOR     = 6, //!< Korean region.
88     REGION_TWN     = 7  //!< Taiwanese region.
89 };
90 
91 /*!
92 @brief  Enumerated type that represents language codes.
93 */
94 enum Language
95 {
96     LANGUAGE_JAPANESE   = 0,  //!< Japanese.
97     LANGUAGE_ENGLISH    = 1,  //!< English.
98     LANGUAGE_FRENCH     = 2,  //!< French.
99     LANGUAGE_GERMAN     = 3,  //!< German.
100     LANGUAGE_ITALIAN    = 4,  //!< Italian.
101     LANGUAGE_SPANISH    = 5,  //!< Spanish.
102     LANGUAGE_CHINESE    = 6,  //!< Chinese (simplified).
103     LANGUAGE_KOREAN     = 7,  //!< Korean.
104     LANGUAGE_DUTCH      = 8,  //!< Dutch.
105     LANGUAGE_PORTUGUESE = 9,  //!< Portuguese.
106     LANGUAGE_RUSSIAN    = 10, //!< Russian.
107     LANGUAGE_TAIWANESE  = 11, //!< Chinese (traditional).
108 
109     LANGUAGE_INVALID    = 255 //!< Invalid language code.
110 };
111 
112 /*!
113 @brief  Enumerated type representing platform types.
114 */
115 enum Platform
116 {
117     PLATFORM_RESERVED_01 = 1,
118     PLATFORM_RESERVED_02 = 2,
119     PLATFORM_CAFE        = 3  //!< Indicates the Wii U.
120 };
121 
122 /*!
123 @brief  Enumerated type representing notification types.
124 */
125 enum NotificationType
126 {
127     NOTIFICATION_NONE               = 0,  //!< Invalid notification.
128     NOTIFICATION_ONLINE             = 1,  //!< Indicates that the local host is currently online.
129     NOTIFICATION_OFFLINE            = 2,  //!< Indicates that the local host is currently offline.
130     NOTIFICATION_PREFERENCE         = 3,  //!< Indicates that the local host's settings have changed.
131     NOTIFICATION_FRIEND_ONLINE      = 4,  //!< Indicates that a friend is currently online.
132     NOTIFICATION_FRIEND_OFFLINE     = 5,  //!< Indicates that a friend is currently offline.
133     NOTIFICATION_FRIEND_PRESENCE    = 6,  //!< Indicates that a friend's presence status has changed.
134     NOTIFICATION_FRIEND_MII         = 7,  //!< Indicates that a friend's Mii character has changed.
135     NOTIFICATION_FRIEND_PROFILE     = 8,  //!< Indicates that a friend's profile has changed.
136     NOTIFICATION_FRIEND_ADDED       = 9,  //!< Indicates that a friend has been added to the friend list.
137     NOTIFICATION_FRIEND_REMOVED     = 10, //!< Indicates that a friend has been removed from the friend list.
138     NOTIFICATION_MY_REQUEST_ADDED   = 11, //!< Indicates that a tentative registrant or a user requesting to be friends has been added to the friend list.
139     NOTIFICATION_MY_REQUEST_REMOVED = 12, //!< Indicates that a tentative registrant or a user requesting to be friends has been deleted from the friend list.
140     NOTIFICATION_MY_REQUEST_UPDATED = 13, //!< Indicates that a friend request has been sent to a tentative registrant or a user requesting to be friends.
141     NOTIFICATION_BLACKLIST_ADDED    = 14, //!< Indicates that a user has been added to the blacklist.
142     NOTIFICATION_BLACKLIST_REMOVED  = 15, //!< Indicates that a user has been removed from the blacklist.
143     NOTIFICATION_BLACKLIST_UPDATED  = 16, //!< Indicates that the information of a user on the blacklist has been updated.
144     NOTIFICATION_REQUEST_ADDED      = 17, //!< Indicates that a user has been added to the request list.
145     NOTIFICATION_REQUEST_REMOVED    = 18, //!< Indicates that a user has been removed from the request list.
146     NOTIFICATION_RESERVED_19        = 19, //
147     NOTIFICATION_RESERVED_20        = 20  //
148 };
149 
150 /*!
151 @brief  Enumerated type representing notification bitmasks.
152 */
153 enum NotificationMask
154 {
155     NOTIFICATION_MASK_ONLINE             = (1 << 0),  //!< Get <tt>NOTIFICATION_ONLINE</tt> notifications.
156     NOTIFICATION_MASK_OFFLINE            = (1 << 1),  //!< Get <tt>NOTIFICATION_OFFLINE</tt> notifications.
157     NOTIFICATION_MASK_PREFERENCE         = (1 << 2),  //!< Get <tt>NOTIFICATION_PREFERENCE</tt> notifications.
158     NOTIFICATION_MASK_FRIEND_ONLINE      = (1 << 3),  //!< Get <tt>NOTIFICATION_FRIEND_ONLINE</tt> notifications.
159     NOTIFICATION_MASK_FRIEND_OFFLINE     = (1 << 4),  //!< Get <tt>NOTIFICATION_FRIEND_OFFLINE</tt> notifications.
160     NOTIFICATION_MASK_FRIEND_PRESENCE    = (1 << 5),  //!< Get <tt>NOTIFICATION_FRIEND_PRESENCE</tt> notifications.
161     NOTIFICATION_MASK_FRIEND_MII         = (1 << 6),  //!< Get <tt>NOTIFICATION_FRIEND_MII</tt> notifications.
162     NOTIFICATION_MASK_FRIEND_PROFILE     = (1 << 7),  //!< Get <tt>NOTIFICATION_FRIEND_PROFILE</tt> notifications.
163     NOTIFICATION_MASK_FRIEND_ADDED       = (1 << 8),  //!< Get <tt>NOTIFICATION_FRIEND_ADDED</tt> notifications.
164     NOTIFICATION_MASK_FRIEND_REMOVED     = (1 << 9),  //!< Get <tt>NOTIFICATION_FRIEND_REMOVED</tt> notifications.
165     NOTIFICATION_MASK_MY_REQUEST_ADDED   = (1 << 10), //!< Get <tt>NOTIFICATION_MY_REQUEST_ADDED</tt> notifications.
166     NOTIFICATION_MASK_MY_REQUEST_REMOVED = (1 << 11), //!< Get <tt>NOTIFICATION_MY_REQUEST_REMOVED</tt> notifications.
167     NOTIFICATION_MASK_MY_REQUEST_UPDATED = (1 << 12), //!< Get <tt>NOTIFICATION_MY_REQUEST_UPDATED</tt> notifications.
168     NOTIFICATION_MASK_BLACKLIST_ADDED    = (1 << 13), //!< Get <tt>NOTIFICATION_BLACKLIST_ADDED</tt> notifications.
169     NOTIFICATION_MASK_BLACKLIST_REMOVED  = (1 << 14), //!< Get <tt>NOTIFICATION_BLACKLIST_REMOVED</tt> notifications.
170     NOTIFICATION_MASK_BLACKLIST_UPDATED  = (1 << 15), //!< Get <tt>NOTIFICATION_BLACKLIST_UPDATED</tt> notifications.
171     NOTIFICATION_MASK_REQUEST_ADDED      = (1 << 16), //!< Get <tt>NOTIFICATION_REQUEST_ADDED</tt> notifications.
172     NOTIFICATION_MASK_REQUEST_REMOVED    = (1 << 17), //!< Get <tt>NOTIFICATION_REQUEST_REMOVED</tt> notifications.
173     NOTIFICATION_MASK_RESERVED_19        = (1 << 18), //
174     NOTIFICATION_MASK_RESERVED_20        = (1 << 19), //
175 
176     NOTIFICATION_MASK_DEFAULT            = 0x000FFFFF //!< The default notification mask.
177 };
178 
179 /*!
180 @brief  Enumerated type representing the status of accepting participation.
181 */
182 enum JoinAvailability
183 {
184     JOIN_AVAILABILITY_NOT_JOINABLE      = 0, //!< Indicates no availability for joining in.
185     JOIN_AVAILABILITY_JOINABLE          = 1, //!< Indicates availability for joining in.
186     JOIN_AVAILABILITY_JOINABLE_APP_ONLY = 2  //!< Indicates that an application is available for joining in, but that friends cannot join from the friend list.
187 };
188 
189 /*!
190 @brief  Enumerated type indicating the conditions under which joining in is allowed.
191 */
192 enum MatchmakeSystemType
193 {
194     MATCHMAKE_SYSTEM_TYPE_INVALID = 0, //!< Invalid value.
195     MATCHMAKE_SYSTEM_TYPE_ANYBODY = 1, //!< Indicates that anyone can join, not just friends.
196     MATCHMAKE_SYSTEM_TYPE_FRIEND  = 2  //!< Indicates that only friends of the group owner can join.
197 };
198 
199 /*!
200 @brief  Enumerated type representing the friend relationship.
201 */
202 enum Relationship
203 {
204     RELATIONSHIP_INVALID = 0, //!< If that friend does not exist, this indicates that the relationship is in an invalid state.
205     RELATIONSHIP_PENDING = 1, //!< Indicates that the relationship is currently pending.
206     RELATIONSHIP_REQUEST = 2, //!< Indicates that the relationship has been requested.
207     RELATIONSHIP_FRIEND  = 3  //!< Indicates that the friend relationship has been established.
208 };
209 
210 //! @}
211 
212 /*---------------------------------------------------------------------------*
213 *  Typedefs
214  *---------------------------------------------------------------------------*/
215 
216 //! @addtogroup  nn_fp_api
217 //! @{
218 
219 /*!
220 @brief  Represents a principal ID.
221 */
222 typedef u32 PrincipalId;
223 
224 /*!
225 @brief  Specifies the message ID of a friend request.
226 */
227 typedef u64 MessageId;
228 
229 /*!
230 @brief  Represents an asynchronous processing complete callback.
231 */
232 typedef void (*AsyncCallback)(nn::Result result, void* pContext);
233 
234 /*!
235 @brief  Represents a notification callback.
236 */
237 typedef void (*NotificationHandler)(NotificationType notificationType, PrincipalId principalId, void* pContext);
238 
239 /*---------------------------------------------------------------------------*
240 *  Structures
241  *---------------------------------------------------------------------------*/
242 
243 /*!
244 @brief  Structure for handling time.
245 */
246 struct DateTime
247 {
248     u16 year;   //!< The year.[1, ...]
249     u8  month;  //!< The month.[1, 12]
250     u8  day;    //!< The day.[1, 31]
251     u8  hour;   //!< The hour.[0, 23]
252     u8  minute; //!< The minute.[0, 59]
253     u8  second; //!< The second.[0, 59]
254     int:8;
255 };
256 
257 /*!
258 @brief  Structure that stores the profile linked with the network account.
259 */
260 struct Profile
261 {
262     u8 country; //!< Country code.
263     u8 area;    //!< A code representing the area of the country for the user, such as a state or province.
264     int:16;
265 };
266 
267 /*!
268 @brief  Structure that stores information about the current game. This information is required for friends to join in.
269 */
270 struct GameMode
271 {
272     u32         joinAvailabilityFlag;                    //!< Indicates whether friends can join in to the same matchmaking group as the local host.
273     u32         matchmakeSystemType;                     //!< The matchmaking type of the matchmaking group in which the local user is participating.
274     u32         joinGameId;                              //!< An ID used to distinguish game titles that the user can join. The title code for one of the games is shared by multiple game titles that allow players to join in.
275     u32         joinGameMode;                            //!< A value used to distinguish what game modes allow friends to join. You can specify any value in the range from 0 through 63.
276     PrincipalId ownerPrincipalId;                        //!< Specifies the principal ID of the host of the matchmaking group in which you are participating.
277     u32         joinGroupId;                             //!< Specifies the ID of the local host's matchmaking group.
278     u8          applicationArg[FP_APPLICATION_ARG_SIZE]; //!< Information that can be freely defined by applications.
279 };
280 
281 /*!
282 @brief  Structure that stores console information.
283 */
284 struct ConsoleInfo
285 {
286     u8 region;   //!< The region code of the console. (See <tt>@ref Region</tt>.)
287     u8 language; //!< The language code of the console. (See <tt>@ref Language</tt>.)
288     u8 platform; //!< The platform code of the console. (See <tt>@ref Platform</tt>.)
289     int:8;
290 };
291 
292 /*!
293 @brief  Structure storing the local user's presence information.
294 */
295 struct MyPresence
296 {
297     GameMode    gameMode;                                      //!< Game mode information that the local host discloses to friends.
298     ConsoleInfo consoleInfo;                                   //!< Console information.
299     char16      gameModeDescription[FP_MODE_DESCRIPTION_SIZE]; //!< Game mode description string that the local host discloses to friends.
300 };
301 
302 /*!
303 @brief  Structure storing friend presence information.
304 */
305 struct FriendPresence
306 {
307     GameMode    gameMode;    //!< Game mode information disclosed by the friend. The data is filled with zeroes if the join-in game IDs of the games being played by the local user and friend are different.
308     ConsoleInfo consoleInfo; //!< Console information.
309     u8          isOnline;    //!< <tt>1</tt> when the friend is online, and <tt>0</tt> otherwise.
310     u8          isValid;     //!< <tt>1</tt> when the data in the obtained structure is valid, and <tt>0</tt> otherwise.
311     int:16;
312 };
313 
314 /*!
315 @brief  Structure that stores configuration information.
316 */
317 struct Preference
318 {
319     u8 isPresencePublication; //!< Indicates whether to publish online status. When this flag is <tt>0</tt>, the local host's presence information is not delivered to friends.
320     u8 isGameNamePublication; //!< Indicates whether to publish the name of the software being played. When this flag is <tt>0</tt>, the local host's presence information is not delivered to friends.
321     u8 isRequestBlockSetting; //!< Indicates the friend request receipt block setting.
322     int:8;
323 };
324 
325 /*!
326 @brief  Structure storing the Player History.
327 
328 One of the <tt>@ref Language</tt>s is stored for the language code. @n
329 Use UTF-16BE for the encoding of display names.
330 */
331 struct RecentPlayRecord
332 {
333     PrincipalId principalId;                               //!< The partner's principal ID.
334     u8          language;                                  //!< The partner's language code.
335     u8          myLanguage;                                //!< The user's language code.
336     char16      inGameName[FP_IN_GAME_SCREEN_NAME_SIZE];   //!< The display name of the partner's in-game character. Set this to the screen name displayed in online multiplayer games.
337     char16      inGameMyName[FP_IN_GAME_SCREEN_NAME_SIZE]; //!< The display name of the user's in-game character. Set this to the screen name displayed in online multiplayer games.
338     int:16;
339 };
340 
341 //! @}
342 
343 }}
344 
345 #endif // __FP_TYPES_H__
346