/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef __FP_API_H__ #define __FP_API_H__ #include namespace nn { namespace fp { /*! @ingroup nn_fp @defgroup nn_fp_api Friend Presence (FP) API @brief A list of Friend Presence (FP) library members. (Includes only C++ API members.) @{ */ //! @name Initializing and Finalizing the Library //! @{ /*! @brief Initializes the friend presence library and makes the presence features available for use. @return Returns the result. */ nn::Result Initialize(void); /*! @brief Finalizes the friend presence library. This call succeeds even if the library is not initialized. @return Returns the result. */ nn::Result Finalize(void); /*! @brief Checks whether the friend presence library is initialized. @return Returns true if the library is initialized, and false otherwise. */ bool IsInitialized(void); //! @} //! @name Connection Management //! @{ /*! @brief Logs in to the friend server. You must establish a network connection before calling this function. This function succeeds even if it is called when the local user has already logged in. @n In such cases, the asynchronous processing instantly completes successfully, but @ref NOTIFICATION_ONLINE is not issued. The local user is guaranteed to be online when the asynchronous processing succeeds. @note If an application is run using something other than caferun (such as the launcher or the friend list viewer), the system might already have completed login before the application starts. For this reason, avoid using only @ref NOTIFICATION_ONLINE to determine whether the user is online. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result LoginAsync(AsyncCallback pCallback, void* pContext); /*! @brief Logs out from the friend server. This function withdraws the login request for the application. @n Because the system may have sent a login request, there is no guarantee of an offline state even if this function succeeds. If the connection with the server is lost for some reason, although it transitions to the offline state implicitly, the login request remains. This function succeeds even if it is called when the local user has already logged out. @return Returns the result. */ nn::Result Logout(void); /*! @brief Checks the login status of the local user. Check whether the local user is online after calling the @ref LoginAsync function. @return Returns true if the local user is logged in; and returns false otherwise. @n The local user is guaranteed to be logged in if this function returns true, but it is not necessarily offline if this function returns false. The function may return false when the system has sent a login request. */ bool HasLoggedIn(void); /*! @brief Checks the online status. Check whether the local user is online, and whether the @ref LoginAsync function has been called. @return Returns true if online, and false otherwise. */ bool IsOnline(void); //! @} //! @name Getting Information About the Local User //! @{ /*! @brief Gets the local principal ID. @return Returns the local principal ID. @n If offline, it returns @ref FP_INVALID_PRINCIPAL_ID. */ PrincipalId GetMyPrincipalId(void); /*! @brief Gets the local account ID. If offline, it returns an empty account ID in the buffer. @n The function still returns success in this case. @param[out] accountId Buffer for storing the account ID of the local user. @return Returns the result. */ nn::Result GetMyAccountId(char accountId[FP_ACCOUNT_ID_SIZE]); /*! @brief Gets the local Mii character display name. If offline, it returns an empty display name in the buffer. @n The function still returns success in this case. Mii character display names sometimes include characters that the application does not support. @n When that happens, you must handle it without adversely affecting the screen display or hindering the application's progress. For more details, see the Nicknames and Creator Names section in the Wii U Guidelines. @param[out] screenName A buffer storing the Mii character display name of the local user. @return Returns the result. */ nn::Result GetMyScreenName(char16 screenName[FP_MII_SCREEN_NAME_SIZE]); /*! @brief Gets local Mii data. If offline, it returns empty Mii data in the buffer. @n The function still returns success in this case. To use the obtained Mii character data, the separate Mii Face Library is required. @param[out] pMiiData A buffer used to store the local Mii. @return Returns the result. */ nn::Result GetMyMii(FFLStoreData* pMiiData); /*! @brief Gets the local profile. If offline, it returns an empty profile in the buffer. @n The function still returns success in this case. @param[out] pProfile A buffer used to store the local profile. @return Returns the result. */ nn::Result GetMyProfile(Profile* pProfile); /*! @brief Gets the local preferences. If offline, it returns empty preferences in the buffer. @n The function still returns success in this case. @param[out] pPreference A buffer used to store the local preferences. @return Returns the result. */ nn::Result GetMyPreference(Preference* pPreference); /*! @brief Gets the local presence information. @param[out] pMyPresence Specifies a buffer that stores the local presence. @return Returns the result. */ nn::Result GetMyPresence(MyPresence* pMyPresence); /*! @brief Confirms whether the initial settings sequence has completed. If the initial settings sequence has not completed, the friend list update function fails. @n Also, this flag may be changed when a @ref NOTIFICATION_PREFERENCE notification arrives. @return Returns true if the initial setting sequence has completed; returns false if it has not. @n If offline, it returns false. */ bool IsPreferenceValid(void); /*! @brief Checks whether the sending of friend requests is allowed. When this flag is false, the function for sending friend requests fails. @n Also, this flag may be changed when a @ref NOTIFICATION_PREFERENCE notification arrives. @return Returns true if the sending of friend requests is allowed, and false otherwise. @n If offline, it returns false. */ bool IsFriendRequestAllowed(void); //! @} //! @name Getting Friend List Information //! @{ /*! @brief Gets the friend list. If offline, the friend list is empty. @n The function still returns success in this case. This function gets only the users that have established friend relationships. Get the number of friends by setting pList to NULL or size to 0. @param[out] pList Specifies a buffer for storing the friend list. @param[out] pNum Specifies a buffer for storing the number of items actually retrieved. @param[in] offset Specifies the index of the first item to retrieve. @param[in] size Specifies the number of elements in the friend list. @return Returns the result. */ nn::Result GetFriendList(PrincipalId* pList, size_t* pNum, size_t offset, size_t size); /*! @brief Gets the friend list. If offline, the friend list is empty. @n The function still returns success in this case. This function includes users who have not yet established friend relationships, such as those who are tentatively registered or who have requests pending. @n Only account IDs and Mii character information can be obtained for these users. It can be used to determine whether a user has already been added to a list before adding friends or sending friend requests. To get just the users with whom friend relationships have been established, use the @ref GetFriendList function. You can get the number of users on the friend list by setting pList to NULL or size to 0. @param[out] pList Specifies a buffer for storing the friend list. @param[out] pNum Specifies a buffer for storing the number of items actually retrieved. @param[in] offset Specifies the index of the first item to retrieve. @param[in] size Specifies the number of elements in the friend list. @return Returns the result. */ nn::Result GetFriendListAll(PrincipalId* pList, size_t* pNum, size_t offset, size_t size); /*! @brief Gets a list of friend account IDs. Returns an empty account ID in the buffer if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pAidList Specifies a buffer for storing the account ID. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendAccountId(char (*pAidList)[FP_ACCOUNT_ID_SIZE], const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of friends' Mii character display names. By calling this function, you can get the name of a friend's Mii character directly without using the Mii Face Library. If the name of the friend's Mii character contains profanity, the name is replaced with question marks ("???"). Returns an empty display name in the buffer if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. Mii character display names sometimes include characters that the application does not support. @n When that happens, you must handle it without adversely affecting the screen display or hindering the application's progress. For more details, see the Nicknames and Creator Names section in the Wii U Guidelines. @param[out] pNameList Specifies a buffer that stores the display names of the friends' Mii characters. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @param[in] replaceForeignCharacters Specifies whether to replace non-ASCII characters with question marks ("?") if the local font region differs from the region of the friend. @param[out] pFontList Specifies a buffer that stores the friends' font regions. @n Specify NULL if not needed. @return Returns the result. */ nn::Result GetFriendScreenName(char16 (*pNameList)[FP_MII_SCREEN_NAME_SIZE], const PrincipalId* pPidList, size_t size, bool replaceForeignCharacters = true, u8* pFontList = NULL); /*! @brief Gets a list of friends' Mii data. Returns empty Mii character data if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. To use the obtained Mii character data, the separate Mii Face Library is required. @param[out] pMiiDataList Specifies a buffer for storing Mii data. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendMii(FFLStoreData* pMiiDataList, const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of profiles of friends. Returns empty profile information if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pProfileList Specifies a buffer for storing profile information. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendProfile(Profile* pProfileList, const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of friend approval times. Puts an empty time in the buffer if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pTimeList Specifies a buffer for storing times. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendApprovalTime(DateTime* pTimeList, const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of friend sort times. Gets the time a friend relationship was established for friends in an established relationship, the expiration date for those in a pending request state, and the registration time for those in a temporary registration state. Puts an empty time in the buffer if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pTimeList Specifies a buffer for storing times. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendSortTime(DateTime* pTimeList, const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of friends' presence information. The function cannot get the game mode of a friend who has specified a different join-in game ID. Returns an empty presence information object if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pPresenceList Specifies a buffer that stores the friends' presence information. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendPresence(FriendPresence* pPresenceList, const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of friend relationships. Returns @ref RELATIONSHIP_INVALID in the buffer if there is no friend corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pRelationList A buffer for storing relationship information. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendRelationship(u8* pRelationList, const PrincipalId* pPidList, size_t size); //! @} //! @name Getting Blacklist Information //! @{ /*! @brief Gets the blacklist. If offline, the blacklist is empty. @n The function still returns success in this case. You can get the number of users on the blacklist by setting pList to NULL or size to 0. @param[out] pList Specifies a buffer for storing the blacklist. @param[out] pNum Specifies a buffer for storing the number of items actually retrieved. @param[in] offset Specifies the index of the first item to retrieve. @param[in] size The number of elements in the blacklist. @return Returns the result. */ nn::Result GetBlackList(PrincipalId* pList, size_t* pNum, size_t offset, size_t size); /*! @brief Gets a list of the account IDs for users who have been added to the blacklist. Returns an empty account ID in the buffer if there is no user corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pAidList Specifies a buffer for storing the account ID. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetBlackListAccountId(char (*pAidList)[FP_ACCOUNT_ID_SIZE], const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of the times when added to the blacklist. Returns an empty time in the buffer if there is no user corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pTimeList Specifies a buffer for storing times. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetBlackListAdditionalTime(DateTime* pTimeList, const PrincipalId* pPidList, size_t size); //! @} //! @name Getting Request List Information //! @{ /*! @brief Gets the request list. If offline, the request list is empty. @n The function still returns success in this case. You can get the number of users on the request list by setting pList to NULL or size to 0. @param[out] pList Specifies a buffer for storing the request list. @param[out] pNum Specifies a buffer for storing the number of items actually retrieved. @param[in] offset Specifies the index of the first item to retrieve. @param[in] size Specifies the number of elements in the request list. @return Returns the result. */ nn::Result GetFriendRequestList(PrincipalId* pList, size_t* pNum, size_t offset, size_t size); /*! @brief Gets a list of the account IDs for users who have been added to the request list. Returns an empty account ID in the buffer if there is no user corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pAidList Specifies a buffer for storing the account ID. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendRequestAccountId(char (*pAidList)[FP_ACCOUNT_ID_SIZE], const PrincipalId* pPidList, size_t size); /*! @brief Gets a list of the message IDs for messages that have been sent by users added to the request list. Returns an empty message ID in the buffer if there is no user corresponding to the principal ID passed in as a parameter. @n The function still returns success in this case. @param[out] pMidList Specifies a buffer for storing the message ID. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @return Returns the result. */ nn::Result GetFriendRequestMessageId(MessageId* pMidList, const PrincipalId* pPidList, size_t size); //! @} //! @name Updating Information About the Local User //! @{ /*! @brief Updates the game mode. Game mode information configured in this function is sent to friends when you are online, and is reflected in their friend lists. The friend list determines which games can be joined according to fixed logic based on this game mode parameter. @n Note that a friend list may erroneously display that join-in is possible if an inappropriate parameter is specified. Set the game mode to the user's online group participation status or application-defined data. @n Parameters set here are shared among applications for which the same join-in game ID is specified. @n This function does not update join-in game IDs. @param[in] pGameMode Specifies the game mode. @param[in] description Specifies a string description of the game mode. @n Use UTF-16BE for the encoding. @return Returns the result. */ nn::Result UpdateGameMode(const GameMode* pGameMode, const char16 description[FP_MODE_DESCRIPTION_SIZE], u32 dummy = 0); /*! @brief Updates the game mode description string. The string set by this function is sent to friends and is displayed in their friend lists when you are online. @n Use "\\n" for newlines. @param[in] description Specifies a string description of the game mode. @n Use UTF-16BE for the encoding. @return Returns the result. */ nn::Result UpdateGameModeDescription(const char16 description[FP_MODE_DESCRIPTION_SIZE]); //! @} //! @name Updating the Friend List //! @{ /*! @brief Adds a friend to the friend list. This function adds a friend to the friend list by specifying the principal ID. When this function succeeds, the new friend is in a tentatively registered state. @n If the other person has already tentatively registered the local user or has sent a friend request to the local user, this function establishes a friend relationship. This function cannot be used when offline. @param[in] principalId Specifies the principal ID. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result AddFriendAsync(PrincipalId principalId, AsyncCallback pCallback, void* pContext); /*! @brief Adds a friend to the friend list. This function adds a friend to the friend list by specifying the account ID. When this function succeeds, the new friend is in a tentatively registered state. @n If the other person has already tentatively registered the local user or has sent a friend request to the local user, this function establishes a friend relationship. This function cannot be used when offline. @param[in] accountId Specifies the account ID. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result AddFriendAsync(const char accountId[FP_ACCOUNT_ID_SIZE], AsyncCallback pCallback, void* pContext); /*! @brief Sends a friend request. When this function succeeds, the new friend is in a request state. @n If the other person has already tentatively registered the local user or has sent a friend request to the local user, this function establishes a friend relationship. If the user is already a friend, the function returns @ref ResultFpdFriendAlreadyAdded. If the user has been tentatively added, the function changes the status to "request pending," and if the status is "request pending," the function updates the request. This function cannot be used when offline. @param[in] principalId Specifies the principal ID of the other user. @param[in] inGameNameLanguage Specifies the language code for displaying the character's name in the game. @n If @ref LANGUAGE_INVALID is specified, the system's language code is used. @param[in] inGameName Specifies the display name of the user's in-game character. @n Use UTF-16BE for the encoding. @param[in] messageLanguage Specifies the language code of the request message. @n If @ref LANGUAGE_INVALID is specified, the system's language code is used. @param[in] message Specifies the request message. @n Use UTF-16BE for the encoding. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result AddFriendRequestAsync(PrincipalId principalId, u8 inGameNameLanguage, const char16 inGameName[FP_IN_GAME_SCREEN_NAME_SIZE], u8 messageLanguage, const char16 message[FP_REQUEST_MESSAGE_SIZE], AsyncCallback pCallback, void* pContext); //! @} //! @name Updating the Blacklist //! @{ /*! @brief Adds users to the blacklist. If the blacklist is already full, the earliest user is discarded to make way for the new registration. @n When adding a user who is already in the blacklist, this function updates the time stamp for when that user was added.
This function cannot be used when offline. @param[in] principalId Specifies the principal ID of the user to add to the blacklist. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result AddBlackListAsync(PrincipalId principalId, AsyncCallback pCallback, void* pContext); //! @} //! @name Updating the Request List //! @{ /*! @brief Accepts a friend request that has been received. If this function succeeds, the user is added to the friend list and the request is deleted from the request list. This function cannot be used when offline. @param[in] messageId Specifies the message ID. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result AcceptFriendRequestAsync(MessageId messageId, AsyncCallback pCallback, void* pContext); /*! @brief Deletes a friend request that has been received. If this function succeeds, the user is removed from the request list. This function cannot be used when offline. @param[in] messageId Specifies the message ID. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result DeleteFriendRequestAsync(MessageId messageId, AsyncCallback pCallback, void* pContext); /*! @brief Rejects a friend request that has been received. If this function succeeds, the user is removed from the request list and added to the blacklist. @n If this user is already on the blacklist, the time he or she was added is updated. This function cannot be used when offline. @param[in] messageId Specifies the message ID. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result DenyFriendRequestAsync(MessageId messageId, AsyncCallback pCallback, void* pContext); //! @} //! @name Updating the Player History //! @{ /*! @brief Adds to the Player History. This function cannot be used if there have been no connections to the account server after the application starts. @n In such cases, the function returns @ref ResultNetworkClockInvalid. The number of records that can be added at the same time is @ref FP_RECENT_PLAY_RECORD_LIST_SIZE. If RecentPlayRecord::myLanguage is set to @ref LANGUAGE_INVALID, the system's language code is used. @note The data added with this function is saved to a file during the finalization process for an application or the system. Press the POWER Button on the console to make the system perform the finalization process. Note that the data is not saved when there is a forced exit, such as with cafestop or a power failure. @param[in] pList Specifies the Player History list. @n Use UTF-16BE for the encoding of in-game display names. @param[in] size Specifies the number of elements in the Player History list. @return Returns the result. */ nn::Result AddRecentPlayRecord(const RecentPlayRecord* pList, size_t size); //! @} //! @name Viewing Data //! @{ /*! @brief Gets the friend request receipt blocking setting for the user linked to the specified principal ID. You can use this function to check whether a recipient's friend request blocking setting is set to on before sending a friend request. The number of block friend request settings that can be retrieved at the same time is @ref FP_REFERENCE_DATA_SIZE. This function cannot be used when offline. @param[out] pSettingList Specifies a buffer for storing the user's block-request settings. @param[in] pPidList Specifies a list of principal IDs. @param[in] size Specifies the number of elements in the principal ID list. @param[in] pCallback Specifies a callback for completion of asynchronous operation. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result GetRequestBlockSettingAsync(u8* pSettingList, const PrincipalId* pPidList, size_t size, AsyncCallback pCallback, void* pContext); //! @} //! @name Join-In //! @{ /*! @brief Determines whether the specified friend can join in. @param[in] pPresence Specifies the presence information of a friend who wishes to join in. @param[in] joinGameModeMask Specifies the join-in game-mode mask. @return .. Returns true if the friend can join in, and false otherwise. @n Returns false if the library has not been initialized. */ bool IsJoinable(const FriendPresence* pPresence, u64 joinGameModeMask); //! @} //! @name Others //! @{ /*! @brief Sets an event handler for notifications of changes to own or a friend's status. @param[in] notificationMask Specifies a bitmask for the notifications you want to receive. @n Specify the notifications that you want to receive by performing a bitwise OR on @ref NotificationMask enumerators. @param[in] pHandler Specifies the notification callback. @param[in] pContext Specifies the callback parameters. @return Returns the result. */ nn::Result SetNotificationHandler(u32 notificationMask, NotificationHandler pHandler, void* pContext); /*! @brief Converts a processing result into an error code. @param[in] result Specifies the result. @return Returns the error code. @n Returns 0 if the results do not require an error code to be displayed, or if the results other than the Friend Presence Library are specified. */ u32 ResultToErrorCode(nn::Result result); //! @} //! @} }} #endif // __FP_API_H__