Nintendo 3DS Miiverse Library  1.3.2
(OLV/Olive)
olv_TypesResume.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*
2 Project: OLV
3 File: olv_TypesResume.h
4 
5 Copyright (C) 2009-2013 Nintendo. 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  *---------------------------------------------------------------------------*/
14 #ifndef __OLV_TYPES_RESUME_H_
15 #define __OLV_TYPES_RESUME_H_
16 
17 /*! @file
18 @brief Declaration of types related to OLV recovery.
19 */
20 
21 #include <nn/config.h>
22 #include <nn/types.h>
23 #include <nn/olv/olv_Const.h>
24 
25 /// <span>nn</span>
26 namespace nn {
27 
28 /// <span>olv</span>
29 namespace olv {
30 
31 namespace internal
32 {
33 class Main;
34 }
35 
36 /*/* @defgroup class Classes
37  * @{
38  */
39 
40 /*!
41 @brief Represents the parameters when recovering.
42 */
44 {
45 public:
46  /*!
47 @brief Instantiates the object.
48  */
49  ResumeParam();
50 
51  /*!
52 @brief Reverts parameters to their initial state.
53  */
54  void Reset();
55 
56  /*!
57 @brief Sets flags.
58 
59 This is for future expansion. It is not used currently.
60 
61 @param[in] flags Flags (<tt>FLAG_*</tt>).
62  */
63  void SetFlags(u32 flags);
64 
65  /*!
66 @brief Sets the system arguments.
67 
68 The system arguments can be obtained by using the <tt>nn::applet::GetInitialParam</tt> function when the application starts, and by using the <tt>nn::applet::WaitForStarting</tt> function when you return from the Miiverse application. For an example of how these are used, see the <tt>StartPortalApp</tt> demo.
69 
70 @param[in] systemArgs The system arguments.
71 @param[in] systemArgsSize The size of the system arguments.
72  */
73  void SetSystemArgs(const u8* systemArgs, u32 systemArgsSize);
74 
75 private:
76  u32 m_Flags;
77  const u8* m_SystemArgs;
78  u32 m_SystemArgsSize;
79  u8 m_Reserved[64-12];
80 
81  friend class nn::olv::internal::Main;
82 };
83 
84 /*!
85 @brief A class that stores the recovery results.
86 */
88 {
89 public:
90  /*!
91 @brief The modes that can be obtained using the <tt>GetMode</tt> function.
92  */
93  enum {
94  MODE_NONE = 0, //!< The default mode.
95  MODE_START_COMMUNITY = MODE_VALUE_START_COMMUNITY, //!< The mode specified when the process is started from the community page.
96  MODE_START_POST = MODE_VALUE_START_POST, //!< The mode specified when the process is started from the post page.
97  MODE_START_USER = MODE_VALUE_START_USER //!< The mode specified when the process is started from the user page.
98  };
99 
100  /*!
101 @brief Flags that can be specified in the <tt>TestFlags</tt> function.
102  */
103  enum
104  {
105  FLAG_NONE = 0, //!< This is the state when no flags are specified.
106  FLAG_WITH_APP_DATA = DOWNLOAD_FLAG_VALUE_WITH_APP_DATA //!< Flag indicating that application data is included.
107  };
108 
109  /*!
110 @brief Instantiates the object.
111  */
112  ResumedData();
113 
114  /*!
115 @brief Reverts parameters to their initial state.
116  */
117  void Reset();
118 
119  /*!
120 @brief Gets the mode.
121 
122 @return Returns the mode (<tt>MODE_*</tt>).
123  */
124  u32 GetMode() const;
125 
126  /*!
127 @brief Tests flags.
128 
129 @param[in] flags Flags (<tt>FLAG_*</tt>).
130 
131 @return Returns <tt>true</tt> if any of the flags are set; returns <tt>false</tt> otherwise. <br />
132  */
133  bool TestFlags(u32 flags) const;
134 
135  /*!
136 @brief Gets the community ID.
137 
138 This function only can be used when the <tt>@ref GetMode</tt> function returns <tt>@ref MODE_START_COMMUNITY</tt>. <br />
139 
140 @return Returns the community ID.
141  */
142  u32 GetCommunityId() const;
143 
144  /*!
145 @brief Gets the post ID.
146 
147 This function only can be used when the <tt>@ref GetMode</tt> function returns <tt>@ref MODE_START_POST</tt>. <br />
148 Note that if you call this function in one of the following invalid states, it will stop on an assertion in the debug/development versions, and return without doing anything in the release version. <br />
149 - If <tt>NULL</tt> is specified for the <span class="argument">postId</span> argument.
150 - If a value less than that of <tt>@ref nn::olv::POST_ID_BUFF_LENGTH</tt> is specified for the <span class="argument">postIdMaxLength</span> argument.
151 
152 @param[out] postId The buffer that stores the post ID.
153 @param[in] postIdMaxLength The length of the buffer that stores the post ID, including the terminating null character. <br />
154 Make sure that you specify a size of at least <tt>@ref nn::olv::POST_ID_BUFF_LENGTH</tt>.
155  */
156  void GetPostId(char* postId, u32 postIdMaxLength) const;
157 
158  /*!
159 @brief Gets the size of the application data.
160 
161 @return Returns the size of the application data.
162  */
163  u32 GetAppDataSize() const;
164 
165  /*!
166 @brief Gets application data.
167 
168 This function can only be used when the return value from the <tt>@ref TestFlags</tt> function is <tt>true</tt> when <tt>@ref FLAG_WITH_APP_DATA</tt> is specified.
169 Note that if you call this function in one of the following invalid states, it will stop on an assertion in the debug/development versions, and return without doing anything in the release version. <br />
170 - If calling the <tt>@ref TestFlags</tt> function with <tt>@ref FLAG_WITH_APP_DATA</tt> specified yields a return value of <tt>false</tt>.
171 - If <tt>NULL</tt> is specified for the <span class="argument">appData</span> argument.
172 - If a value less than that returned by the <tt>@ref GetAppDataSize</tt> function is specified for the <span class="argument">appDataMaxSize</span> argument.
173 
174 @param[out] appData The buffer that stores the application data.
175 @param[in] appDataMaxSize The size of the buffer that stores the application data. <br />
176 Make sure that you specify a value of at least that returned by the <tt>@ref GetAppDataSize</tt> function.
177  */
178  void GetAppData(u8* appData, u32 appDataMaxSize) const;
179 
180  /*!
181 @brief Gets the principal ID of the user.
182 
183 This function only can be used when the <tt>@ref GetMode</tt> function returns <tt>@ref MODE_START_USER</tt>. <br />
184 
185 @return Returns the principal ID of the user.
186  */
187  u32 GetUserPid() const;
188 
189 private:
190  u32 m_Mode;
191  u32 m_Flags;
192  u32 m_CommunityId;
193  u8* m_PostId;
194  u32 m_PostIdLength;
195  u8* m_AppData;
196  u32 m_AppDataSize;
197  u32 m_UserPid;
198  u8 m_CommonData[4096-32];
199 
200  friend class nn::olv::internal::Main;
201 };
202 
203 /** @} */
204 
205 } // namespace olv
206 } // namespace nn
207 #endif