1 /*---------------------------------------------------------------------------*
2 
3 Copyright (C) 2013-2014 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_EC_SHOPPING_CATALOG_H_
14 #define NN_EC_SHOPPING_CATALOG_H_
15 
16 #include <nn/ec/ec_Catalog.h>
17 #include <nn/ec/ec_Query.h>
18 
19 namespace nn { namespace ec {
20 
21 //! @addtogroup nn_ec_class
22 //! @{
23 
24 /*!
25 @brief Class for handling a shopping catalog.
26 
27 @see        <a class="el" href="../../Doc/EcdkProgrammingManual/contents/Pages/Page_48711722.html#PageId_48712105">Programming Manual</a>
28 */
29 class ShoppingCatalog : public Catalog
30 {
31 public:
32     NN_EC_DECLARE_ACCESSOR;
33     NN_EC_DECLARE_IMPL;
34 
35 public:
36     /*!
37 @brief      The maximum number of items you want to get.
38     */
39     static const u32 ITEM_NUM_MAX = 100;
40 
41 public:
42     /*!
43 @brief Instantiates the object.
44     */
45     ShoppingCatalog();
46 
47     /*!
48 @brief Destroys the object.
49     */
50     ~ShoppingCatalog();
51 
52     /*!
53 @brief Gets a list of downloadable content.
54 
55 This function calls <tt>@ref Clear</tt> before retrieving the list. @n
56 The reference counters of previously retrieved items are decremented by 1, so make note of the persistence of items retrieved with <tt>@ref GetItem</tt>.
57 
58 This function blocks because it involves communication.
59 
60 @param[in] pQuery  Specifies the query. @n
61 Specify <tt>NULL</tt> if you are not using a query.
62 @param[in] startIndex  Specifies the start position.
63 @param[in] num  Specifies the number of items to retrieve. @n
64 The maximum number that can be specified is <tt>@ref ITEM_NUM_MAX</tt>.
65 
66 @return The result of processing.
67 
68 @retval Result::IsSuccess Indicates success.
69 @retval ResultNotInitialized  Indicates that the library is not initialized.
70 @retval     ResultNotLoggedIn       Not logged in to the eShop server.
71 @retval ResultInvalidArgument  Indicates that an argument is invalid.
72 @retval     ResultOutOfMemory       Insufficient memory.
73 @retval     ResultNotConnected      Not connected to the Internet.
74 @retval     ResultCanceled          The communication process was canceled.
75 @retval     ResultExcluded          The EC applet is running.
76 @retval     ResultResponseError     A response error occurred.
77 @retval     ResultCurlError         A communication error occurred.
78 @retval     ResultServerError       A server error occurred.
79 @retval     Other                  Sometime an error generated by <tt>@ref Login</tt> is returned.
80     */
81     nn::Result RetrieveAocs(const Query* pQuery, u32 startIndex, u32 num);
82 
83     /*!
84 @brief Gets an item list from a download code.
85 
86 This function calls <tt>@ref Clear</tt> before retrieving the list. @n
87 The reference counters of previously retrieved items are decremented by 1, so make note of the persistence of items retrieved with <tt>@ref GetItem</tt>.
88 
89 This function returns <tt>@ref ResultWrongDownloadCode</tt> if the specified code is not a download code for an item that can be used by the application.
90 
91 This function blocks because it involves communication.
92 
93 @param[in] pQuery  Specifies the query. @n
94 Specify <tt>NULL</tt> if you are not using a query. @n
95 Values other than <tt>@ref Query::Select</tt> are ignored.
96 @param[in] pDownloadCode  Specifies the download code. @n
97 The function returns <tt>@ref ResultInvalidArgument</tt> if the specified value is not a 16-digit alphanumeric string.
98 @param[in] num  Specifies the number of items to retrieve. @n
99 If multiple items can be retrieved, specify the maximum number. @n
100 The maximum number that can be specified is <tt>@ref ITEM_NUM_MAX</tt>.
101 
102 @return The result of processing.
103 
104 @retval Result::IsSuccess Indicates success.
105 @retval ResultNotInitialized  Indicates that the library is not initialized.
106 @retval     ResultNotLoggedIn       Not logged in to the eShop server.
107 @retval ResultInvalidArgument  Indicates that an argument is invalid.
108 @retval     ResultOutOfMemory       Insufficient memory.
109 @retval     ResultNotConnected      Not connected to the Internet.
110 @retval     ResultCanceled          The communication process was canceled.
111 @retval     ResultExcluded          The EC applet is running.
112 @retval     ResultWrongDownloadCode     Not a valid download code.
113 @retval     ResultResponseError     A response error occurred.
114 @retval     ResultCurlError         A communication error occurred.
115 @retval     ResultServerError       A server error occurred.
116 @retval     Other                  Sometime an error generated by <tt>@ref Login</tt> is returned.
117     */
118     nn::Result RetrieveWithDownloadCode(const Query* pQuery, const char* pDownloadCode, u32 num = 1);
119 
120     /*!
121 @brief Gets the total number of items that can be retrieved.
122 
123 The value returned by this function does not depend on the number of items to retrieve as specified in <tt>Retrieve*</tt>.
124 
125 You must call <tt>Retrieve*</tt> before calling this function. @n
126 This function returns <tt>0</tt> if an item list could not be retrieved with <tt>Retrieve*</tt>.
127 
128 @return Returns the total number of retrievable items.
129 
130 @see        RetrieveAocs
131 @see        RetrieveWithDownloadCode
132     */
133     u32 GetTotal() const;
134 
135 private:
136     //
137     Impl* CreateImpl(u32 num);
138 };
139 
140 //! @}
141 
142 }} // namespace nn::ec
143 
144 #endif // NN_EC_SHOPPING_CATALOG_H_
145