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_RAWULTASKSETTING_H_
14 #define NN_BOSS_BOSS_RAWULTASKSETTING_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_NetTaskSetting.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 a <tt>RawUL</tt> task. Used when registering tasks (passed as an argument to <tt>@ref Task::Register</tt>).
33 */
34 class RawUlTaskSetting : public NetTaskSetting
35 {
36 public:
37 /*!
38     @brief  Instantiates an object.
39 */
40     explicit RawUlTaskSetting(void);
41 
42 /*!
43     @brief  Destroys the object.
44 */
45     virtual ~RawUlTaskSetting(void);
46 
47 /*!
48 @brief  Initializes the settings of a <tt>RawUL</tt> task. If initialization succeeds, you can register the information using the <tt>@ref Task::Register</tt> function.
49 
50 @param[in] url  Specifies the connection URL.
51 @param[in] pUploadData  Specifies a pointer to the beginning of the data to upload. Do not free this data until the <tt>@ref Task::Register</tt> function completes.
52 @param[in] uploadDataSize  Specifies the size of the data to upload.
53 @return  Returns the result of execution. Returns one of the following <tt>Result</tt> values.
54 @retval Result::IsSuccess  Indicates successful retrieval.
55 @retval ResultInvalidParameter  Indicates an invalid parameter.
56 */
57     nn::Result Initialize(const char* url, const u8* pUploadData, s64 uploadDataSize);
58 
59 /*!
60 @brief  Initializes the settings of a <tt>RawUL</tt> task. If initialization succeeds, you can register the information using the <tt>@ref Task::Register</tt> function.
61 
62 @param[in] url  Specifies the connection URL.
63 @param[in] uploadFilePath  Specifies the file path to the data to upload. Do not delete this file until the <tt>@ref Task::Register</tt> function completes.
64 @param[in] pUploadWorkBuffer  Specifies a pointer to the start of memory to use as a working buffer during upload. It is used to copy the data uploaded using <tt>@ref Task::Register</tt>. It is also used as the <var>dest</var> argument to the <tt>FSReadFile</tt> function, so the buffer alignment must be compatible with this function. The larger the size of the buffer that you provide, the faster the <tt>@ref Task::Register</tt> function completes. Do not free this memory until the <tt>@ref Task::Register</tt> function completes.
65 @param[in] uploadWorkBufferSize  Specifies the size of <var>pUploadWorkBuffer</var>.
66 @return  Returns the result of execution. Returns one of the following <tt>Result</tt> values.
67 @retval Result::IsSuccess  Indicates successful retrieval.
68 @retval ResultInvalidParameter  Indicates an invalid parameter.
69 */
70     nn::Result Initialize(const char* url, const char* uploadFilePath, u8* pUploadWorkBuffer, s64 uploadWorkBufferSize);
71 
72 /*!
73 @brief  [Deprecated] Do not use.
74 
75 This functionality is now implemented by the <tt>Initialize(const char* url, const char* uploadFilePath, u8* pUploadWorkBuffer, s64 uploadWorkBufferSize)</tt> function. Use that function instead.
76 
77 @deprecated
78 */
79     nn::Result Initialize(const char* url, const char* uploadFilePath);
80 
81 /*!
82 @brief  Specifies processing options.
83 
84 @param[in] option  Specifies the option to set. Please contact Nintendo about the available options.
85 @return  Returns the result of execution. Returns one of the following <tt>Result</tt> values.
86 @retval Result::IsSuccess  Indicates successful retrieval.
87 @retval ResultInvalidParameter  Indicates an invalid parameter.
88 */
89     nn::Result SetOption(u32 option);
90 
91 /*!
92 @brief  Adds the <tt>RawUL</tt> custom header to the request for sending by HTTP.
93 This function can add headers to an HTTP request that are larger than the maximum value allowed by the <tt>AddHttpHeader</tt> function for ordinary custom headers (512 bytes).
94 The maximum number that can be added is 1.
95 
96 @param[in] label  Specifies the label string for the <tt>RawUL</tt> custom header being added.
97 @param[in] value  Specifies the value string for the <tt>RawUL</tt> custom header being added.
98 @return  Returns the result of execution. Returns one of the following <tt>Result</tt> values.
99 @retval Result::IsSuccess  Indicates successful retrieval.
100 @retval ResultInvalidParameter  Indicates an invalid parameter.
101 @retval ResultAlreadyExist  Indicates that a custom header has already been added.
102 */
103     nn::Result AddLargeHttpHeader(const char* label, const char* value);
104 
105 /*!
106 @brief  Clears the <tt>RawUL</tt> custom header previously added to the HTTP request headers.
107 */
108     void ClearLargeHttpHeader(void);
109 
110 protected:
111     const u8*  m_pUploadData;
112     s64  m_uploadDataSize;
113     char m_uploadFilePath[FILEFULLPATH_MAX_LENGTH_WITH_NULL];
114 
115     virtual nn::Result RegisterPreprocess( nn::boss::AccountID accountId, nn::boss::TitleID titleId, const char* taskId );
116 private:
117     nn::Result CopyUploadFileToBossStorage( nn::boss::AccountID accountId, nn::boss::TitleID titleId, const char* taskId ) const;
118 
119     void SetRawUlTaskSettingToRecord( const char* url );
120 
121     virtual void RegisterPostprocess( nn::boss::AccountID accountId, nn::boss::TitleID titleId, const char* taskId, nn::Result registerResult);
122 };
123 
124 //! @}
125 
126 } // end of namespace boss
127 } // end of namespace nn
128 
129 #endif // __cplusplus
130 
131 #endif /* NN_BOSS_BOSS_RAWULTASKSETTING_H_ */
132