1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     boss_NsaList.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46667 $
14  *---------------------------------------------------------------------------*/
15 
16 
17 #ifndef NN_BOSS_BOSS_NSALIST_H_
18 #define NN_BOSS_BOSS_NSALIST_H_
19 
20 #include <nn/os/os_CriticalSection.h>
21 #include <nn/boss/boss_FgOnlyTask.h>
22 
23 #ifdef __cplusplus
24 
25 namespace nn {
26 namespace boss {
27 
28 /* Please see man pages for details
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 */
47 class NsaList
48 {
49 public:
50     /* Please see man pages for details
51 
52     */
53     enum ParseResult
54     {
55         NN_BOSS_NSALIST_PARSE_ERROR_INVALID_POINTER        = -1,  //
56         NN_BOSS_NSALIST_PARSE_ERROR_INVALID_WORK_BUF_SIZE  = -2,  //
57         NN_BOSS_NSALIST_PARSE_ERROR_FILE_INITIALIZE_FAILED = -3,  //
58         NN_BOSS_NSALIST_PARSE_ERROR_FILE_GETSIZE_FAILED    = -4,  //
59         NN_BOSS_NSALIST_PARSE_ERROR_FILE_READ_FAILED       = -5,  //
60         NN_BOSS_NSALIST_PARSE_ERROR_FILE_INVALID_FORMAT    = -6,  //
61         NN_BOSS_NSALIST_PARSE_RESULT_MAX_VALUE             = 999  //
62     };
63 
64     static const u32 NN_BOSS_NSALIST_WAIT_FINISH_TIMEOUT_DEFAULT_SEC = 30;  //
65     static const s64 NN_BOSS_NSALIST_MAX_SIZE = 236054;                     //
66 
67 public:
68     /* Please see man pages for details
69 
70 
71 
72 
73 
74     */
75     struct SearchAttributes
76     {
77         char* attribute1;
78         char* attribute2;
79         char* attribute3;
80     };
81 
82     /* Please see man pages for details
83 
84     */
85     struct NsaInformation
86     {
87         char fileName[32];     //
88         u32  fileSize;         //
89         u32  updateEpochTime;  //
90         char attribute1[10];   //
91         char attribute2[10];   //
92         char attribute3[10];   //
93         u8   caption[150];     //
94     };
95 
96 public:
97 /* Please see man pages for details
98 
99 
100 */
101     explicit NsaList(const char* nsaListFilePath);
102 
103 /* Please see man pages for details
104 
105 */
106     virtual ~NsaList(void);
107 
108 
109 /* Please see man pages for details
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 */
126     nn::Result Download(const char* bossCode, const char* taskId, const SearchAttributes* attributes = NULL, u32 waitTimeoutSec = NN_BOSS_NSALIST_WAIT_FINISH_TIMEOUT_DEFAULT_SEC, s64 fileSize = NN_BOSS_NSALIST_MAX_SIZE);
127 
128 
129 /* Please see man pages for details
130 
131 
132 
133 
134 
135 
136 */
137     nn::Result Cancel(void);
138 
139 
140 /* Please see man pages for details
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 */
155     u32 GetHttpStatusCode(void);
156 
157 
158 /* Please see man pages for details
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 */
180     TaskResultCode GetResult(void);
181 
182 
183 /* Please see man pages for details
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 */
197     ParseResult Parse(u32* pOutParseCount, NsaInformation pNsaInformationArray[], u32 nsaInformationArraySize, void* pWorkBuf, size_t workBufSize, u32 nsaFirstPos = 0);
198 
199 
200  /* Please see man pages for details
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214  */
215     nn::Result GetDigest(u8* pDigestBuf, size_t digestBufSize);
216 
217  /* Please see man pages for details
218 
219 
220 
221 
222 
223  */
224     bool CheckValidity(void* pWorkBuf, size_t workBufSize);
225 
226 private:
227     nn::Result RegisterWaitEvent(nn::os::Event* pEvent);
228     nn::Result UnregisterWaitEvent(nn::os::Event* pEvent);
229     nn::Result WaitFinishWaitEvent(void);
230     nn::Result WaitFinishWaitEvent(const nn::fnd::TimeSpan& timeout);
231     nn::Result WaitFinish(void);
232     nn::Result WaitFinish(const nn::fnd::TimeSpan& timeout);
233     void CancelWaitFinish(void);
234 
235 private:
236     bool m_IsCanceled;
237     NN_PADDING3;
238 
239     nn::os::CriticalSection m_Cs;
240     nn::os::Event* m_pWaitEvent;
241 
242     const char* m_NsaListFilePath;
243 
244     FgOnlyTask m_FgTask;
245 };
246 
247 } // end of namespace boss
248 } // end of namespace nn
249 
250 #endif // __cplusplus
251 #endif /* NN_BOSS_BOSS_NSALIST_H_ */
252