Nintendo 3DS Miiverse Library  1.3.2
(OLV/Olive)
olv_TypesDownloadUserData.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*
2  Project: OLV
3  File: olv_TypesDownloadUserData.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_DOWNLOAD_USERDATA_H_
15 #define __OLV_TYPES_DOWNLOAD_USERDATA_H_
16 
17 /*! @file
18  @brief OLV type declarations related to the downloading of user data.
19 */
20 
22 
23 /// <span>nn</span>
24 namespace nn {
25 
26 /// <span>olv</span>
27 namespace olv {
28 
29 namespace internal
30 {
31 class Main;
32 }
33 
34 /*/* @defgroup class Classes
35  * @{
36  */
37 
38 /*!
39  @brief The class representing the parameters used when downloading user data.
40 */
42 {
43 public:
44  /*!
45  @brief Flags that can be specified in the <tt>@ref SetFlags</tt> function.
46 
47  A flag other than <tt>FLAG_NONE</tt> must be specified. <br />
48  Only one flag can be specified.
49  */
50  enum
51  {
52  FLAG_NONE = 0, //!< This is the state when no flags are specified.
53  FLAG_FRIEND_TO_USER = (1<<0), //!< Downloads user data from friends of the specified user. Specify the target user with the <tt>@ref SetUserPid</tt> function.
54  FLAG_FOLLOW_TO_USER = (1<<1), //!< Downloads user data from the users that the specified user is following. Specify the target user with the <tt>@ref SetUserPid</tt> function.
55  FLAG_EMPATHY_TO_POST = (1<<2), //!< Downloads user data from users who have given a Yeah to the specified post. Specify the target post with the <tt>@ref SetPostId</tt> function.
56  FLAG_FAVORITE_TO_COMMUNITY = (1<<3), //!< Downloads user data from users who have registered the specified community as a favorite. Specify the target community with the <tt>@ref SetCommunityId</tt> function.
57  FLAG_WITH_MII_DATA = (1<<4) //!< Downloads user data including the Mii data.
58  };
59 
60  /*!
61  @brief Instantiates the object.
62  */
64 
65  /*!
66  @brief Reverts parameters to their initial state.
67  */
68  void Reset();
69 
70  /*!
71  @brief Sets flags.
72 
73  You must specify this option.
74 
75  @param[in] flags Flags (<tt>FLAG_*</tt>).
76  */
77  void SetFlags(u32 flags);
78 
79  /*!
80  @brief Sets the principal ID.
81 
82  Specifying this option is not required. <br />
83  Specify <tt>@ref FLAG_FRIEND_TO_USER</tt> or <tt>@ref FLAG_FOLLOW_TO_USER</tt> at the same time. <br />
84  When the principal ID for some user is specified, the user data is downloaded for the friends of that user or the people being followed by that user. <br />
85 
86  @param[in] userPid The principal ID. <br />
87  */
88  void SetUserPid(u32 userPid);
89 
90  /*!
91  @brief Sets the post ID.
92 
93  Specifying this option is not required. <br />
94  Specify <tt>@ref FLAG_EMPATHY_TO_POST</tt> at the same time. <br />
95  When this is specified, the user data is downloaded for users who have given a Yeah to the specified post. <br />
96 
97  @param[in] postId The post ID. <br />
98  The maximum number of characters that can be specified is <tt>@ref nn::olv::POST_ID_BUFF_LENGTH - 1</tt>.
99  */
100  void SetPostId(const char* postId);
101 
102  /*!
103  @brief Sets the community ID.
104 
105  Specifying this option is not required. <br />
106  Specify <tt>@ref FLAG_FAVORITE_TO_COMMUNITY</tt> at the same time. <br/>
107  When this is specified, the user data is downloaded for users who have registered the specified community as a favorite. <br />
108 
109  @param[in] communityId The community ID. <br />
110  */
111  void SetCommunityId(const u32 communityId);
112 
113  /*!
114  @brief Sets the maximum amount of user data to download.
115 
116  You must specify this option.
117 
118  @param[in] userDataMaxNum The maximum amount of user data to download. <br />
119  Make sure that the number of arrays in the <span class="argument">userDataList</span> parameter of the <tt>@ref nn::olv::DownloadUserDataList</tt> function is equal to or greater than this value. <br />
120  */
121  void SetUserDataMaxNum(u32 userDataMaxNum);
122 
123  /*!
124  @brief Gets the size of the working buffer to use with the <tt>@ref nn::olv::DownloadUserDataList</tt> function.
125 
126  Call this function after all of the various parameters have been specified, with the exception of the <tt>@ref SetWork</tt> function. <br />
127  This function returns fixed values.
128 
129  @return Returns the size of the working buffer to use with the <tt>@ref nn::olv::DownloadUserDataList</tt> function.
130  */
131  u32 GetWorkSize() const;
132 
133  /*!
134  @brief Specifies the size of the working buffer to use with the <tt>@ref nn::olv::DownloadUserDataList</tt> function.
135 
136  You must specify this option. <br />
137  Specify a buffer of at least the size obtained with the <tt>@ref GetWorkSize</tt> function. <br />
138 
139  @param[in] work The working buffer.
140  @param[in] workSize The size of the working buffer.
141  */
142  void SetWork(u8* work, u32 workSize);
143 
144 private:
145  u32 m_Flags;
146  u8* m_Work;
147  u32 m_WorkSize;
148  u32 m_UserPid;
149  u32 m_CommunityId;
150  s8 m_IsSetCommunityId;
151  NN_PADDING3;
152  u32 m_UserDataMaxNum;
153  char m_PostId[POST_ID_BUFF_LENGTH];
154  u8 m_Reserved[1024-60];
155 
156  friend class nn::olv::internal::Main;
157 };
158 
159 /*!
160  @brief The class for storing the downloaded user data.
161 */
163 {
164 public:
165  /*!
166  @brief Flags that can be specified in the <tt>@ref TestFlags</tt> function.
167  */
168  enum
169  {
170  FLAG_NONE = 0, //!< This is the state when no flags are specified.
171  FLAG_WITH_MII_DATA = DOWNLOAD_FLAG_VALUE_WITH_MII_DATA //!< This flag indicates that the user data includes Mii data.
172  };
173 
174  /*!
175  @brief Instantiates the object.
176  */
178 
179  /*!
180  @brief Reverts parameters to their initial state.
181  */
182  void Reset();
183 
184  /*!
185  @brief Tests flags.
186 
187  @param[in] flags Flags (<tt>FLAG_*</tt>).
188 
189  @return Returns <tt>true</tt> if any of the flags are set; returns <tt>false</tt> otherwise.
190  */
191  bool TestFlags(u32 flags) const;
192 
193  /*!
194  @brief Gets the principal ID of the user.
195 
196  @return Returns the principal ID of the user.
197  */
198  u32 GetUserPid() const;
199 
200  /*!
201  @brief Gets the Mii data of the user.
202 
203  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_MII_DATA</tt> is specified. <br />
204  <br />
205  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 />
206  - If calling the <tt>@ref TestFlags</tt> function with <tt>@ref FLAG_WITH_MII_DATA</tt> specified yields a return value of <tt>false</tt>.
207  - If <tt>NULL</tt> is specified for the <span class="argument">storeData</span> argument.
208 
209  @param[out] storeData The buffer that stores the Mii data. <br />
210  */
211  void GetMiiData(nn::mii::StoreData* storeData) const;
212 
213  /*!
214  @brief Gets the nickname of the Mii of the user.
215 
216  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 />
217  - If <tt>NULL</tt> is specified for the <span class="argument">miiNickname</span> argument.
218  - If a value less than that of <tt>@ref nn::olv::MII_NICKNAME_BUFF_LENGTH</tt> is specified for the <span class="argument">miiNicknameMaxLength</span> argument.
219 
220  @param[out] miiNickname The buffer that stores the nickname of the Mii. <br />
221  @param[in] miiNicknameMaxLength The length of the buffer that stores the nickname of the Mii, including the terminating null character. <br />
222  Make sure that you specify a size of at least <tt>@ref nn::olv::MII_NICKNAME_BUFF_LENGTH</tt>.
223  */
224  void GetMiiNickname(wchar_t* miiNickname, u32 miiNicknameMaxLength) const;
225 
226 private:
227  u32 m_Flags;
228  u32 m_UserPid;
229  u8 m_MiiData[MII_DATA_BUFF_LENGTH];
230  wchar_t m_MiiNickname[MII_NICKNAME_BUFF_LENGTH];
231  u8 m_Reserved[2048-168];
232 
233  friend class nn::olv::internal::Main;
234 };
235 
236 /** @} */
237 
238 } // namespace olv
239 } // namespace nn
240 #endif