2e246b3d7f54d1cfc02b4dfe2bc7137497b628b8
[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 <FContent.h>
59  *
60  * using namespace Tizen::Base;
61  * using namespace Tizen::Base::Collection;
62  * using namespace Tizen::Content;
63  *
64  * void
65  * MyClass::Test(void)
66  * {
67  *      // Call Construct() of ContentDirectory
68  *      ContentDirectory directory;
69  *      const Tizen::Base::String contentDirectoryPath = L"";
70  *      result r = directory.Construct(CONTENT_TYPE_AUDIO);
71  *      if (IsFailed(r))
72  *      {
73  *              // Do something for an error
74  *      }
75  *
76  *      // Call GetContentDirectoryItemListN() of ContentDirectory as the first page
77  *      int pageNo = 1;
78  *      int countPerPage = 5;
79  *      int totalPage = 0;
80  *      int totalCount = 0;
81  *      IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage, L"Title", SORT_ORDER_ASCENDING);
82  *                               
83  *      if (IsFailed(GetLastResult()))
84  *      {
85  *              // Do something for an error
86  *      }
87  *
88  *      // Delete resource
89  *      pContentInfoList->RemoveAll(true);
90  *      delete pContentInfoList;
91  * }
92  *
93  * @endcode
94  *
95  */
96
97 class _OSP_EXPORT_ ContentDirectory
98         : public Tizen::Base::Object
99 {
100
101 public:
102
103         /**
104          * The object is not fully constructed after this constructor is called. @n
105          * For full construction, the Construct() method must be called right after calling this constructor.
106          *
107          * @since 2.0
108          */
109         ContentDirectory(void);
110
111         /**
112          * This destructor overrides Tizen::Base::Object::~Object().
113          *
114          * @since 2.0
115          */
116         virtual ~ContentDirectory(void);
117
118         /**
119          * Initializes this instance of %ContentDirectory with the specified parameter.
120          *
121          * @since 2.0
122          *
123          * @return    An error code
124          * @param     contentType          The content type @n
125          *                                                         This method is used to access only one type of content @n
126          *                                                         The allowed types are @c CONTENT_TYPE_OTHER, @c CONTENT_TYPE_IMAGE, @c CONTENT_TYPE_AUDIO,
127          *                                                         and @c CONTENT_TYPE_VIDEO @n
128          *                                                         If you want to access more than one type of content, use Construct(const Tizen::Base::Collection::IListT<ContentType>&)
129          *                                                         instead of this method.
130          * @exception E_SUCCESS        The method is successful.
131          * @exception E_INVALID_ARG    The specified input parameter is invalid.
132          * @exception E_OUT_OF_MEMORY  The memory is insufficient.
133          * @exception E_SYSTEM         The method cannot connect to the database.
134          */
135         result Construct(ContentType contentType);
136
137         /**
138          * Initializes this instance of %ContentDirectory with the specified parameter.
139          *
140          * @since 2.0
141          *
142          * @return    An error code
143          * @param     contentTypeList   The list of content types @n
144          *                                                          This method is used to access more than one type of content, but the total count should not be greater than @c 4 @n
145          *                                                          The allowed types are @c CONTENT_TYPE_OTHER, @c CONTENT_TYPE_IMAGE, @c CONTENT_TYPE_AUDIO,
146          *                                                          and @c CONTENT_TYPE_VIDEO @n
147          *                                                              Any combination with @c CONTENT_TYPE_ALL is a invalid argument @n
148          *                                                          If you want to access only one type of content, use Construct(ContentType) instead of this method.
149          * @exception E_SUCCESS         The method is successful.
150          * @exception E_INVALID_ARG     The specified input parameter is invalid.
151          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
152          * @exception E_SYSTEM          The method cannot connect to the database.
153          */
154         result Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList);
155
156         /**
157          * Gets the count of the content directories that contain the content type that is passed as a parameter to Construct().
158          *
159          * @since 2.0
160          *
161          * @return    The count of the content directories
162          * @exception E_SUCCESS                 The method is successful.
163          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
164          * @exception E_SERVICE_BUSY    The database is busy.
165          * @exception E_SYSTEM          The method cannot access the database.
166          * @remarks The specific error code can be accessed using the GetLastResult() method.
167          */
168         int GetContentDirectoryCount(void) const;
169
170         /**
171          * Gets the list of content directory paths that contain the content type that is passed as a parameter to Construct().
172          *
173          * @since 2.0
174          *
175          * @return    The list of Tizen::Base::String values that contain the content directory paths
176          * @param     sortOrder                 The sort order
177          * @exception E_SUCCESS         The method is successful.
178          * @exception E_INVALID_ARG     The specified input parameter is invalid.
179          * @exception E_OUT_OF_MEMORY   The memory is insufficient.
180          * @exception E_SERVICE_BUSY    The database is busy.
181          * @exception E_SYSTEM          The method cannot access the database.
182          * @remarks The specific error code can be accessed using the GetLastResult() method.
183          */
184         Tizen::Base::Collection::IList* GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const;
185
186         
187         /**
188          * Gets the file count in the directory.
189          *
190          * @since 2.0
191          *
192          * @return    The file count
193          * @param     contentDirectoryPath              The content directory path @n
194          *                                                                              The allowed directory path can be obtained by using
195          *                                                                              Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
196          * @exception E_SUCCESS                 The method is successful.
197          * @exception E_INVALID_ARG             The specified input parameter is invalid.
198          * @exception E_OUT_OF_MEMORY           The memory is insufficient.
199          * @exception E_SERVICE_BUSY            The database is busy.
200          * @exception E_SYSTEM                  The method cannot access the database.
201          * @remarks The specific error code can be accessed using the GetLastResult() method.
202          * @see GetContentDirectoryPathListN()
203          */
204         int GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const;
205
206         /**
207          * Gets the list of content information in the directory.
208          *
209          * @since 2.0
210          *
211          * @return    The list of ContentInfo classes that contain the content information
212          * @param     contentDirectoryPath              The content directory path @n
213          *                                                                              The allowed directory path can be obtained by using
214          *                                                                              Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
215          * @param     pageNo                                    The page number @n
216          *                                                                              It must be either greater than or equal to @c 1.
217          * @param     countPerPage                              The count of the search results per page @n
218          *                                                                              It must be either greater than or equal to @c 1.
219          * @param     column                                    The sort column name
220          * @param     sortOrder                                 The sort order
221          * @exception E_SUCCESS                                 The method is successful.
222          * @exception E_INVALID_ARG                             A specified input parameter is invalid.
223          * @exception E_OUT_OF_MEMORY                   The memory is insufficient.
224          * @exception E_SERVICE_BUSY                    The database is busy.
225          * @exception E_SYSTEM                                  The method cannot access the database.
226          * @remarks The specific error code can be accessed using the GetLastResult() method.
227          * @see GetContentDirectoryPathListN()
228          */
229         Tizen::Base::Collection::IList* GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
230                                                                                 const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const;
231
232 private:
233         /**
234          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
235          */
236         ContentDirectory(const ContentDirectory& rhs);
237
238         /**
239          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
240          */
241         ContentDirectory& operator =(const ContentDirectory& rhs);
242
243         _ContentDirectoryImpl* __pImpl;
244
245         friend class _ContentDirectoryImpl;
246
247 };  // class ContentDirectory
248
249 }}  // Tizen::Content
250
251 #endif  // _FCNT_CONTENT_DIRECTORY_H_