[content] Remove useless DB filed info in ContentDirectory
[platform/framework/native/content.git] / src / inc / FCnt_ContentDirectoryImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FCnt_ContentDirectoryImpl.h
19  * @brief               This is the header file for the %_ContentDirectoryImpl class.
20  *
21  * This header file contains the declarations of the %_ContentDirectoryImpl class.
22  */
23
24 #ifndef _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_
25 #define _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_
26
27 #include <glib.h>
28 #include <unique_ptr.h>
29 #include <media_content.h>
30 #include <FBaseColIListT.h>
31 #include <FBaseColAllElementsDeleter.h>
32
33 namespace Tizen { namespace Content
34 {
35         static const int MAX_FIELD_LENGTH  = 32;
36         static const int MAX_QUERY_COLUMNS = 20;
37         static const int MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS = 14;
38         static const int MAX_QUERY_COLUMNS_FOR_VIDEO = 18;
39         static const int ALBUM_COLUMN_NUM = 19;
40
41         typedef struct
42         {
43                 char            dbFieldOspName[MAX_FIELD_LENGTH];
44                 char            dbFieldSlpName[MAX_FIELD_LENGTH];
45         }DatabaseFieldInfo;
46
47         const static DatabaseFieldInfo dbfieldinfo[MAX_QUERY_COLUMNS] =
48         {
49                 //for all types 0 -13
50                 {"ContentType", "MEDIA_TYPE"},
51                 {"ContentFileName", "MEDIA_DISPLAY_NAME"},
52                 {"ContentName", "MEDIA_CONTENT_NAME"},
53                 {"Category", "MEDIA_CATEGORY"},
54                 {"Author", "MEDIA_AUTHOR"},
55                 {"keyword", "MEDIA_KEYWORD"},
56                 {"Provider", "MEDIA_PROVIDER"},
57                 {"Rating", "MEDIA_AGE_RATING"},
58                 {"LocationTag", "MEDIA_LOCATION_TAG"},
59                 {"ContentSize", "MEDIA_SIZE"},
60                 {"DateTime", "MEDIA_ADDED_TIME"},
61                 {"Latitude", "MEDIA_LATITUDE"},
62                 {"Longitude", "MEDIA_LONGITUDE"},
63                 {"Altitude", "MEDIA_ALTITUDE"},
64                 //  for audio and video type 14 - 17
65                 {"Title", "MEDIA_TITLE"},
66                 {"Artist", "MEDIA_ARTIST"},
67                 {"Genre", "MEDIA_GENRE"},
68                 {"Year", "MEDIA_YEAR"},
69                 // for audio type 18 - 19
70                 {"Composer", "MEDIA_COMPOSER"},
71                 {"Album", "MEDIA_ALBUM"}
72         };
73
74 class ContentSearchResult;
75 class ContentDirectory;
76
77 struct GListDeleter
78 {
79         void operator()(GList* pGList)
80         {
81                 g_list_free(pGList);
82                 pGList = NULL;
83         }
84 };
85
86 struct FolderHandleDeleter
87 {
88         void operator()(media_folder_h folderHandle)
89         {
90                 media_folder_destroy(folderHandle);
91                 folderHandle = NULL;
92         }
93 };
94
95 struct MediaHandleDeleter
96 {
97         void operator()(media_info_h mediaHandle)
98         {
99                 media_info_destroy(mediaHandle);
100                 mediaHandle = NULL;
101         }
102 };
103
104 struct FilterHandleDeleter
105 {
106         void operator()(filter_h* pFilterHandle)
107         {
108                 media_filter_destroy(*pFilterHandle);
109         }
110 };
111
112 class _ContentDirectoryImpl
113         : public Tizen::Base::Object
114 {
115 public:
116
117         /**
118          * This is the default constructor for this class.
119          *
120          * @since 2.1
121          */
122         _ContentDirectoryImpl(void);
123
124         /**
125          * This is the destructor for this class.
126          *
127          * @since 2.1
128          */
129         virtual ~_ContentDirectoryImpl(void);
130
131         /**
132          * @see @ref Tizen::Content::ContentDirectory::Construct()
133          */
134         result Construct(ContentType type);
135
136         /**
137          * @see @ref Tizen::Content::ContentDirectory::Construct()
138          */
139         result Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList);
140
141         /**
142          * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryCount()
143          */
144         int GetContentDirectoryCount(void) const;
145
146         /**
147          * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryPathListN()
148          */
149         Tizen::Base::Collection::IList* GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const;
150
151         /**
152          * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryItemCount()
153          */
154         int GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const;
155
156         /**
157          * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryItemListN()
158          */
159         Tizen::Base::Collection::IList* GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
160                                                     const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const;
161
162         static _ContentDirectoryImpl* GetInstance(ContentDirectory& contentDirectory);
163
164         static const _ContentDirectoryImpl* GetInstance(const ContentDirectory& contentDirectory);
165
166 private:
167         _ContentDirectoryImpl(const _ContentDirectoryImpl& rhs);
168         _ContentDirectoryImpl& operator =(const _ContentDirectoryImpl& rhs);
169
170         result CreateFolderFilter(bool isMultiContentType, const Tizen::Base::String& folderPath) const;
171         result FillFinalOutList(char* pFolderId) const;
172         result GetSlpColumnName(Tizen::Base::String& inputCol, Tizen::Base::String sortCol) const;
173         result MapCoreErrorToNativeResult(int reason) const;
174         bool CheckMediaPath(const Tizen::Base::String& directoryPath) const;
175
176         mutable std::unique_ptr<filter_h, FilterHandleDeleter> __pFilterHandle;
177         mutable std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pFinalOutList;
178         ContentType     __contentType;
179         bool __isMultiContentType;
180         Tizen::Base::String __multiContentTypeExpr;
181
182
183 };      // class _ContentDirectoryImpl
184
185 }}      // Tizen::Content
186
187 #endif  // _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_