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 NN_BOSS_BOSS_LIB_H_
14 #define NN_BOSS_BOSS_LIB_H_
15 
16 
17 #include <nn/boss/boss_Const.h>
18 #include <nn/boss/boss_Result.h>
19 #include <nn/boss/boss_Types.h>
20 
21 
22 #ifdef __cplusplus
23 
24 namespace nn {
25 namespace boss {
26 
27 /*!
28 @addtogroup  nn_boss
29   @{
30 
31   @defgroup nn_boss_api  SpotPass (BOSS) API
32   @brief  Members of the SpotPass (BOSS) library API. (Includes only C++ API members.)
33   @{
34 */
35 
36 /*!
37 @brief  Initializes the SpotPass (BOSS) library. You must call this function once before using the BOSS library.
38 
39 @return  Returns the result of the function. Returns one of the following <tt>Result</tt> values.
40 @retval Result::IsSuccess  Indicates that initialization succeeded.
41 @retval Other  Indicates an unexpected error. (For more information, see <tt>@ref nn_boss_result</tt>.)
42 */
43     nn::Result Initialize( void );
44 
45 /*!
46 @brief  Finalizes the SpotPass (BOSS) library. Call this function once when you are finished using the BOSS library.
47 
48 If another BOSS function is being called at the point this function is called, this function blocks until the other call ends. Contemplate this when a blocking BOSS function is being called.
49 If you want to use BOSS again after calling this function, you must call <tt>@ref Initialize</tt> again.
50 This function does not run finalization on individual tasks and has no effect on tasks registered by the caller. In other words, calling this function does not end or suspend any tasks.
51 */
52     void Finalize(void);
53 
54 /*!
55 @brief  Determines whether the library has been initialized.
56 
57 @return  Returns <tt>true</tt> if it is already initialized and <tt>false</tt> if it is not yet initialized.
58 */
59     bool IsInitialized(void);
60 
61 /*!
62 @brief  Gets a list of registered task IDs.
63 
64 Gets a list of the registered task IDs for the account in the specified slot that were registered by the calling application.
65 (Set <tt>0</tt> for <var>slotNo</var> to target the account that is logged in at the time of the call.)
66 If a buffer with a size equal to or greater than the number of tasks registered by applications is set for the <var>taskIdList</var> parameter, you can retrieve a list of all registered tasks at one time.
67 If you specify a small buffer for the <var>taskIdList</var> parameter, you can get a partial task ID list by specifying the number of the task from which to start retrieving IDs for the <var>startPos</var> parameter.
68 To get all of the registered task IDs, run the API function multiple times and change the value specified for the <var>startPos</var> parameter.
69 
70 @param[in] slotNo  Specifies a slot in the target account.
71 @param[out] taskIdList  Specifies a <tt>TaskID</tt> array for storing a list of task IDs. The number of array elements must match the value of <var>elementCount</var>.
72 @param[in] elementCount  Specifies the number of elements in <var>taskIdList</var>.
73 @param[out] getIdCount  Stores the obtained number of task IDs.
74 @param[in] startPos  Specifies the position, among all task IDs, of the first task ID to get. You can call this function repeatedly, using a <var>taskIdList</var> with a small number of elements, to get all of the task IDs. If omitted, elements are obtained starting with the first task ID in the list.
75 @return  Returns the result of the function. Returns one of the following <tt>Result</tt> values.
76 @retval Result::IsSuccess  Indicates successful retrieval.
77 @retval ResultNotCompleted  Could not get all of the task IDs.
78 @retval ResultNotExist  The specified task ID does not exist.
79 @retval ResultInvalidParameter  Invalid argument.
80 @retval ResultLibraryNotInitialized  Indicates that the session is not initialized.
81 The function returns this <tt>Result</tt> if it is called before <tt>@ref Initialize</tt> is called.
82 Always call the <tt>@ref Initialize</tt> function before you use the BOSS library.
83 */
84     nn::Result GetTaskIdList(u8 slotNo, TaskID taskIdList[], u32 elementCount, u32* getIdCount, u32 startPos = 0);
85 
86 /*!
87 @brief  Gets the BOSS state.
88 
89 @return  Returns the state of BOSS. For the definitions of each value, see the descriptions of the <tt>@ref BossState</tt> enumerators.
90 */
91     BossState GetBossState(void);
92 
93 /*!
94 @brief  Returns the error code for the execution result of an API function.
95 
96 If a BOSS API function returns a <tt>nn::Result</tt> type representing an error, you can use this function to convert the result into an error code.
97 This function returns <tt>0</tt> if passed a <var>result</var> representing success (<tt>result.IsSuccess()</tt> returns <tt>true</tt>).
98 
99 @param[in] result  The <tt>nn::Result</tt> instance to convert.
100 @return  Returns the error code.
101 */
102     u32 GetErrorCode( nn::Result result );
103 
104 
105 /*!
106 @deprecated  This API function is not supported. Do not use it.
107 */
108     nn::Result RegisterRootCa(const char* pName, const u8* pCertData, size_t certDataSize, AccountID accountId = 0);
109 
110 /*!
111 @deprecated  This API function is not supported. Do not use it.
112 */
113     nn::Result RegisterClientCert(const char* pCertName, const u8* pCertData, size_t certDataSize, const char* pKeyName, const u8* pPrivateKeyData, size_t privateKeyDataSize, AccountID accountId = 0);
114 
115 /*!
116 @deprecated  This API function is outdated. Do not use it.
117 */
118     nn::Result GetTaskIdList(TaskID taskIdList[], u32 elementCount, u32* getIdCount, AccountID accountId = 0, u32 startPos = 0);
119 
120 /*!
121   @}
122   @}
123 */
124 
125 } // end of namespace boss
126 } // end of namespace nn
127 
128 #endif // __cplusplus
129 
130 #endif /* NN_BOSS_BOSS_LIB_H_ */
131