1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) 2012 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_NETTASKSETTING_H_ 14 #define NN_BOSS_BOSS_NETTASKSETTING_H_ 15 16 #include <nn/boss/boss_Const.h> 17 #include <nn/boss/boss_Result.h> 18 #include <nn/boss/boss_Types.h> 19 #include <nn/boss/boss_TaskSetting.h> 20 21 #ifdef __cplusplus 22 23 namespace nn { 24 namespace boss { 25 26 /*! 27 @addtogroup nn_boss_api 28 @{ 29 */ 30 31 /*! 32 @brief Represents settings for network-related tasks. 33 34 The class that makes the task settings for the task that handles the network processing normally inherits this class. 35 This inheritance enables the use of the methods of this class in common to set the network-related task attributes for any task settings class. 36 */ 37 class NetTaskSetting : public TaskSetting 38 { 39 public: 40 /*! 41 @brief Constructor. 42 */ 43 explicit NetTaskSetting(void); 44 45 /*! 46 @brief Destructor. 47 */ 48 virtual ~NetTaskSetting(void); 49 50 51 /*! 52 @brief Sets the HTTP communication information. Applications do not need to use this member function directly. Used by subclasses representing concrete task settings (such as <tt>@ref NbdlTaskSetting</tt>). 53 54 @param[in] protocol Specifies the communication protocol. 55 @param[in] url Specifies the connection URL. <tt>@ref URL_MAX_LENGTH_WITH_NULL</tt> defines the maximum length, including the terminating <tt>NULL</tt> character. 56 @param[in] option Specifies communication options. Current 57 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 58 @retval Result::IsSuccess Successfully retrieved. 59 @retval ResultInvalidParameter Invalid parameter. 60 */ 61 nn::Result SetConnectionSetting(HttpProtocol protocol, const char* url, u16 option = 0); 62 63 64 /*! 65 @brief Sets the value of <tt>If-Modified-Since</tt> to the <tt>LastModifiedTime</tt> value when a task is executing for the first time. 66 67 When tasks are run for the second (or subsequent) time, the <tt>LastModifiedTime</tt> value obtained in the HTTP response header the previous time the task was run is automatically set to <tt>If-Modified-Since</tt>. 68 If settings are not made with this method, the first time the task is run it is not given an <tt>If-Modified-Since</tt> request header. 69 Use this method only if you want to give the task an <tt>If-Modified-Since</tt> request header when it is first run. 70 71 @param[in] pFirstLastModifiedTime The <tt>LastModifiedTime</tt> value to set. This string is used as the <tt>If-Modified-Since</tt> request header value without modification. <tt>@ref HTTP_LAST_MODIFIED_TIME_STR_MAX_LENGTH_WITH_NULL</tt> defines the maximum length, including the terminating <tt>NULL</tt> character. 72 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 73 @retval Result::IsSuccess Successfully retrieved. 74 @retval ResultInvalidParameter Invalid parameter. 75 */ 76 nn::Result SetFirstLastModifiedTime(const char* pFirstLastModifiedTime); 77 78 /*! 79 @brief Adds a custom header sent by the task in HTTP communication. 80 81 Multiple custom headers can be added. 82 The string set is sent as is in the [<i>label string</i>]:[<i>value string</i>] format. 83 <tt>@ref HTTP_REQUEST_PRIVATE_HEADER_MAX_COUNT</tt> defines the maximum number of custom headers that can be added. 84 85 @param[in] label The label string for the custom header being added. <tt>@ref HTTP_REQUEST_HEADER_LABEL_MAX_LENGTH_WITH_NULL</tt> defines the maximum length, including the terminating <tt>NULL</tt> character. 86 @param[in] value The value string for the custom header being added. <tt>@ref HTTP_REQUEST_HEADER_VALUE_MAX_LENGTH_WITH_NULL</tt> defines the maximum length, including the terminating <tt>NULL</tt> character. 87 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 88 @retval Result::IsSuccess Successfully retrieved. 89 @retval ResultInvalidParameter Invalid parameter. 90 @retval ResultFull The maximum number of custom headers have already been registered. 91 */ 92 nn::Result AddHttpHeader(const char* label, const char* value); 93 94 95 /*! 96 @brief Clears all registered custom headers. 97 */ 98 void ClearHttpHeaders( void ); 99 100 /*! 101 @brief Adds a custom query sent by the task in HTTP communication. 102 103 You can add multiple queries. 104 You can set <tt>@ref QueryKind</tt> to any value that can be obtained from the console, and send this as the query. 105 <tt>@ref HTTP_PRIVATE_QUERY_MAX_COUNT</tt> defines the maximum number of custom queries that can be added. 106 107 @param[in] name Specifies the name component of the custom query. <tt>@ref HTTP_PRIVATE_QUERY_NAME_MAX_LENGTH_WITH_NULL</tt> defines the maximum length, including the terminating <tt>NULL</tt> character. 108 @param[in] kind Specifies the custom query value type. 109 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 110 @retval Result::IsSuccess Successfully retrieved. 111 @retval ResultInvalidParameter Invalid parameter. 112 @retval ResultFull The maximum number of custom queries have already been registered. 113 */ 114 nn::Result AddHttpQueryString(const char* name, QueryKind kind); 115 116 /*! 117 @brief Clears all registered custom query strings. 118 */ 119 void ClearHttpQueryStrings( void ); 120 121 122 /*! 123 @brief Adds a built-in CA certificate. 124 125 You can add multiple built-in CA certificates. 126 <tt>@ref HTTP_INTERNAL_CACERT_MAX_COUNT</tt> defines the maximum number of built-in CA certificates that can be added. 127 128 @param[in] caCertId The ID of the CA certificate to add. If you must use an internal CA certificate, contact Nintendo for an ID. 129 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 130 @retval Result::IsSuccess Successfully retrieved. 131 @retval ResultFull The maximum number of custom certificates have already been installed. 132 */ 133 nn::Result AddInternalCaCert(s8 caCertId); 134 135 /*! 136 @brief [Unsupported API Function.] 137 138 Adds a custom CA certificate. 139 140 @param[in] name The name of the custom certificate to install. 141 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 142 @retval Result::IsSuccess Successfully retrieved. 143 @retval ResultInvalidParameter Invalid parameter. 144 @retval ResultFull The maximum number of custom certificates have already been installed. 145 */ 146 nn::Result AddCaCert(const char* name); 147 148 /*! 149 @brief Clears all registered custom certificate information. 150 */ 151 void ClearCaCertSetting( void ); 152 153 154 /*! 155 @brief Sets a built-in client certificate. 156 157 You can set only one built-in client certificate. If the argument is omitted, the Wii U console's internal client certificate is configured. 158 159 @param[in] clientCertId Specifies the ID of the built-in client certificate. If you must use a built-in client authentication certificate, contact Nintendo for an ID. 160 */ 161 void SetInternalClientCert(s8 clientCertId = 1); 162 163 /*! 164 @brief [Unsupported API Function.] 165 166 Adds a custom client certificate. 167 168 @param[in] certName Specifies the name of the custom certificate to add. 169 @param[in] keyName Specifies the name of the key to add. 170 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 171 @retval Result::IsSuccess Successfully retrieved. 172 @retval ResultInvalidParameter Invalid parameter. 173 */ 174 nn::Result SetClientCert(const char* certName, const char* keyName); 175 176 /*! 177 @brief Clears all registered custom certificate information. 178 */ 179 void ClearClientCertSetting( void ); 180 181 /*! 182 @brief Sets the service token. Use this function when you want to authenticate a client on the server using a service token obtained from the account server. 183 184 The specified service token is included in HTTP request headers when making an HTTP request. 185 186 @param[in] serviceToken Specifies the service token to set. The value of <tt>@ref SERVICE_TOKEN_SIZE</tt> bytes. 187 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 188 @retval Result::IsSuccess Successfully retrieved. 189 @retval ResultInvalidParameter Invalid parameter. 190 */ 191 nn::Result SetServiceToken(const u8 serviceToken[SERVICE_TOKEN_SIZE]); 192 193 /*! 194 @brief Specifies communications options. Applications do not need to use this member function directly. Used by subclasses representing concrete task settings (such as <tt>@ref NbdlTaskSetting</tt>). 195 196 @param[in] option Specifies the option to set. Please contact Nintendo about the options that you can set. 197 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 198 @retval Result::IsSuccess Successfully retrieved. 199 @retval ResultInvalidParameter Invalid parameter. 200 */ 201 nn::Result SetHttpOption(u16 option); 202 203 /*! 204 @brief Specifies the timeout time for HTTP communications. The unit is seconds. Use this function when you want to modify the default timeout time. 205 206 In HTTP communications performed when executing tasks, if no data is communicated for this length of time, the task results in a timeout error. 207 Tasks that are not explicitly specified with this method have a timeout time value of <tt>@ref DEFAULT_TASK_HTTP_TIMEOUT_SEC</tt>. 208 209 @param[in] timeoutSec Specifies the timeout value to set. The unit is seconds. 210 @return Returns the result of execution. Returns one of the following <tt>Result</tt> values. 211 @retval Result::IsSuccess Successfully retrieved. 212 @retval ResultInvalidParameter Invalid parameter. 213 */ 214 nn::Result SetHttpTimeout(u32 timeoutSec); 215 216 }; 217 218 // @} 219 220 } // end of namespace boss 221 } // end of namespace nn 222 223 #endif // __cplusplus 224 225 #endif /* NN_BOSS_BOSS_NETTASKSETTING_H_ */ 226