Fix : Remove exception handling codes at the sample code
[platform/framework/native/content.git] / inc / FCntContentDirectory.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                FCntContentDirectory.h
18  * @brief               This is the header file for the %ContentDirectory class.
19  *
20  * This header file contains the declarations of the %ContentDirectory class.
21  */
22
23 #ifndef _FCNT_CONTENT_DIRECTORY_H_
24 #define _FCNT_CONTENT_DIRECTORY_H_
25
26 #include <FBaseString.h>
27 #include <FBaseColIListT.h>
28 #include <FCntTypes.h>
29
30 namespace Tizen { namespace Base { namespace Collection
31 {
32 class IList;
33 }}}
34
35 namespace Tizen { namespace Content
36 {
37         static const int MAX_CONTENTTYPE_LIST_COUNT = 5;
38         static const int MIN_CONTENTTYPE_LIST_COUNT = 0;
39         static const int CONTENTTYPE_LIST_COUNT_ONE = 1;
40
41 class _ContentDirectoryImpl;
42 /**
43  * @class       ContentDirectory
44  * @brief       This class provides methods for the content directory.
45  * @since       2.0
46  *
47  * @final       This class is not intended for extension.
48  *
49  * The %ContentDirectory class provides methods to access a list of content directories 
50  * and the information of the content (specified content type) in the content directories.
51  *
52  * For more information on the database columns and their corresponding content types, 
53  * see <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">Content Search on the Device</a>.
54  *
55  * The following example demonstrates how to use the %ContentDirectory class.
56  *
57  * @code
58  * #include <FBase.h>
59  * #include <FContent.h>
60  *
61  * using namespace Tizen::Content;
62  *
63  * void
64  * MyClass::Test(void)
65  * {
66  *              ContentDirectory contentDirectory;
67  *              const Tizen::Base::String contentDirectoryPath = L"";
68  *              result r = contentDirectory.Construct(CONTENT_TYPE_AUDIO);
69  *
70  *              int pageNo = 1;
71  *              int countPerPage = 5;
72  *              int totalPage = 0;
73  *              int totalCount = 0;
74  *              Tizen::Base::Collection::IList* pContentInfoList = contentDirectory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage, L"Title", SORT_ORDER_ASCENDING);
75  *              r = GetLastResult();
76  *
77  *              pContentInfoList->RemoveAll(true);
78  *              delete pContentInfoList;
79  * }
80  *
81  * @endcode
82  *
83  */
84
85 class _OSP_EXPORT_ ContentDirectory
86         : public Tizen::Base::Object
87 {
88
89 public:
90
91         /**
92          * The object is not fully constructed after this constructor is called. @n
93          * For full construction, the Construct() method must be called right after calling this constructor.
94          *
95          * @since 2.0
96          */
97         ContentDirectory(void);
98
99         /**
100          * This destructor overrides Tizen::Base::Object::~Object().
101          *
102          * @since 2.0
103          */
104         virtual ~ContentDirectory(void);
105
106         /**
107          * Initializes this instance of %ContentDirectory with the specified parameter.
108          *
109          * @since 2.0
110          *
111          * @return    An error code
112          * @param     contentType          The content type @n
113          *                                                         This method is used to access only one type of content @n
114          *                                                         The allowed types are @c CONTENT_TYPE_OTHER, @c CONTENT_TYPE_IMAGE, @c CONTENT_TYPE_AUDIO,
115          *                                                         and @c CONTENT_TYPE_VIDEO @n
116          *                                                         If you want to access more than one type of content, use Construct(const Tizen::Base::Collection::IListT<ContentType>&)
117          *                                                         instead of this method.
118          * @exception E_SUCCESS        The method is successful.
119          * @exception E_INVALID_ARG    The specified input parameter is invalid.
120          * @exception E_OUT_OF_MEMORY  The memory is insufficient.
121          * @exception E_SYSTEM         The method cannot connect to the database.
122          */
123         result Construct(ContentType contentType);
124
125         /**
126          * Initializes this instance of %ContentDirectory with the specified parameter.
127          *
128          * @since 2.0
129          *
130          * @return    An error code
131          * @param     contentTypeList   The list of content types @n
132          *                                                          This method is used to access more than one type of content, but the total count should not be greater than @c 4 @n
133          *                                                          The allowed types are @c CONTENT_TYPE_OTHER, @c CONTENT_TYPE_IMAGE, @c CONTENT_TYPE_AUDIO,
134          *                                                          and @c CONTENT_TYPE_VIDEO @n
135          *                                                              Any combination with @c CONTENT_TYPE_ALL is a invalid argument @n
136          *                                                          If you want to access only one type of content, use Construct(ContentType) instead of this method.
137          * @exception E_SUCCESS         The method is successful.
138          * @exception E_INVALID_ARG     The specified input parameter is invalid.
139          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
140          * @exception E_SYSTEM          The method cannot connect to the database.
141          */
142         result Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList);
143
144         /**
145          * Gets the count of the content directories that contain the content type that is passed as a parameter to Construct().
146          *
147          * @since 2.0
148          *
149          * @return    The count of the content directories
150          * @exception E_SUCCESS                 The method is successful.
151          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
152          * @exception E_SERVICE_BUSY    The database is busy.
153          * @exception E_SYSTEM          The method cannot access the database.
154          * @remarks The specific error code can be accessed using the GetLastResult() method.
155          */
156         int GetContentDirectoryCount(void) const;
157
158         /**
159          * Gets the list of content directory paths that contain the content type that is passed as a parameter to Construct().
160          *
161          * @since 2.0
162          *
163          * @return    The list of Tizen::Base::String values that contain the content directory paths
164          * @param     sortOrder                 The sort order
165          * @exception E_SUCCESS         The method is successful.
166          * @exception E_INVALID_ARG     The specified input parameter is invalid.
167          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
168          * @exception E_SERVICE_BUSY    The database is busy.
169          * @exception E_SYSTEM          The method cannot access the database.
170          * @remarks The specific error code can be accessed using the GetLastResult() method.
171          */
172         Tizen::Base::Collection::IList* GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const;
173
174         
175         /**
176          * Gets the file count in the directory.
177          *
178          * @since 2.0
179          *
180          * @return    The file count
181          * @param     contentDirectoryPath              The content directory path @n
182          *                                                                              The allowed directory path can be obtained by using
183          *                                                                              Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
184          * @exception E_SUCCESS                 The method is successful.
185          * @exception E_INVALID_ARG             The specified input parameter is invalid.
186          * @exception E_OUT_OF_MEMORY           The memory is insufficient.
187          * @exception E_SERVICE_BUSY            The database is busy.
188          * @exception E_SYSTEM                  The method cannot access the database.
189          * @remarks The specific error code can be accessed using the GetLastResult() method.
190          * @see GetContentDirectoryPathListN()
191          */
192         int GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const;
193
194         /**
195          * Gets the list of content information in the directory.
196          *
197          * @since 2.0
198          *
199          * @return    The list of ContentInfo classes that contain the content information
200          * @param     contentDirectoryPath              The content directory path @n
201          *                                                                              The allowed directory path can be obtained by using
202          *                                                                              Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
203          * @param     pageNo                                    The page number @n
204          *                                                                              It must be either greater than or equal to @c 1.
205          * @param     countPerPage                              The count of the search results per page @n
206          *                                                                              It must be either greater than or equal to @c 1.
207          * @param     column                                    The sort column name
208          * @param     sortOrder                                 The sort order
209          * @exception E_SUCCESS                                 The method is successful.
210          * @exception E_INVALID_ARG                             A specified input parameter is invalid.
211          * @exception E_OUT_OF_MEMORY                   The memory is insufficient.
212          * @exception E_SERVICE_BUSY                    The database is busy.
213          * @exception E_SYSTEM                                  The method cannot access the database.
214          * @remarks The specific error code can be accessed using the GetLastResult() method.
215          * @see GetContentDirectoryPathListN()
216          */
217         Tizen::Base::Collection::IList* GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
218                                                                                 const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const;
219
220 private:
221         /**
222          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
223          */
224         ContentDirectory(const ContentDirectory& rhs);
225
226         /**
227          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
228          */
229         ContentDirectory& operator =(const ContentDirectory& rhs);
230
231         _ContentDirectoryImpl* __pImpl;
232
233         friend class _ContentDirectoryImpl;
234
235 };  // class ContentDirectory
236
237 }}  // Tizen::Content
238
239 #endif  // _FCNT_CONTENT_DIRECTORY_H_