merge with master
[platform/framework/native/content.git] / src / inc / FCnt_ContentManagerImpl.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_ContentManagerImpl.h
19  * @brief               This is the header file for the %_ContentManagerImpl class.
20  *
21  * This header file contains the declarations of the %_ContentManagerImpl class.
22  */
23
24 #ifndef _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_
25 #define _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_
26
27 #include <unique_ptr.h>
28 #include <media_content.h>
29 #include <FCntContentInfo.h>
30
31 namespace Tizen { namespace Content
32 {
33
34 class ContentManager;
35 class IContentScanListener;
36 class IContentUpdateEventListener;
37
38 typedef struct media_info_s* media_info_h;
39
40 struct MediaInfoDeleter
41 {
42         void operator()(media_info_h* pMediaInfo)
43         {
44                 int val = media_info_destroy(*pMediaInfo);
45                 SysLog(NID_CNT, "media_info_destroy result[%d].", val);
46         }
47 };
48
49 struct ImageMetaDeleter
50 {
51         void operator()(image_meta_h* pImageMeta)
52         {
53                 int val = image_meta_destroy(*pImageMeta);
54                 SysLog(NID_CNT, "image_meta_destroy result[%d].", val);
55         }
56 };
57
58 struct AudioMetaDeleter
59 {
60         void operator()(audio_meta_h* pAudioMeta)
61         {
62                 int val = audio_meta_destroy(*pAudioMeta);
63                 SysLog(NID_CNT, "audio_meta_destroy result[%d].", val);
64         }
65 };
66
67 struct VideoMetaDeleter
68 {
69         void operator()(video_meta_h* pVideoMeta)
70         {
71                 int val = video_meta_destroy(*pVideoMeta);
72                 SysLog(NID_CNT, "video_meta_destroy result[%d].", val);
73         }
74 };
75
76 struct ScanResult
77 {
78         char* pScanPath;
79         IContentScanListener* pScanListener;
80         RequestId requestId;
81 };
82
83 class _ContentManagerImpl
84         : public Tizen::Base::Object
85 {
86 public:
87         /**
88          * This is the default constructor for this class.
89          *
90          * @since 2.1
91          */
92         _ContentManagerImpl(void);
93
94         /**
95          * This is the destructor for this class.
96          *
97          * @since 2.1
98          */
99         virtual ~_ContentManagerImpl(void);
100
101         /**
102          * @see @ref Tizen::Content::ContentManager::Construct()
103          */
104         result Construct(void);
105
106         /**
107          * @see @ref Tizen::Content::ContentManager::CreateContent(const ContentInfo&)
108          */
109         ContentId CreateContent(const ContentInfo& contentInfo);
110
111         /**
112          * @see @ref Tizen::Content::ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
113          */
114         ContentId CreateContent(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Base::String& destinationPath, const ContentInfo* pContentInfo = null);
115
116         /**
117          * @see @ref Tizen::Content::ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*)
118          */
119         ContentId CreateContent(const Tizen::Base::String& sourcePath, const Tizen::Base::String& destinationPath, bool deleteSource, const ContentInfo* pContentInfo = null);
120
121         /**
122          * @see @ref Tizen::Content::ContentManager::GetContentInfoN()
123          */
124         ContentInfo* GetContentInfoN(const ContentId& contentId) const;
125
126         /**
127          * @see @ref Tizen::Content::ContentManager::UpdateContent()
128          */
129         result UpdateContent(const ContentInfo& contentInfo);
130
131         /**
132          * @see @ref Tizen::Content::ContentManager::DeleteContent()
133          */
134         result DeleteContent(const ContentId& contentId);
135
136         /**
137          * @see @ref Tizen::Content::ContentManager::AddContentUpdateEventListener()
138          */
139         result AddContentUpdateEventListener(IContentUpdateEventListener& listener);
140
141         /**
142          * @see @ref Tizen::Content::ContentManager::RemoveContentUpdateEventListener()
143          */
144         result RemoveContentUpdateEventListener(IContentUpdateEventListener& listener);
145
146         /**
147          * @see @ref Tizen::Content::ContentManager::ScanFile()
148          */
149         static result ScanFile(const Tizen::Base::String& contentPath);
150
151         /**
152          * @see @ref Tizen::Content::ContentManager::ScanDirectory()
153          */
154         static result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId);
155
156         /**
157          * Gets the Impl instance.
158          *
159          * @since 2.1
160          * @return      The pointer to _ContentManagerImpl
161          * @param[in] contentManager            An instance of ContentManager
162          */
163         static _ContentManagerImpl* GetInstance(ContentManager& contentManager);
164
165         /**
166          * Gets the Impl instance.
167          *
168          * @since 2.1
169          * @return      The pointer to _ContentManagerImpl
170          * @param[in] contentManager            An instance of ContentManager
171          */
172         static const _ContentManagerImpl* GetInstance(const ContentManager& contentManager);
173
174         void SetListener(IContentUpdateEventListener* pListener);
175
176         IContentUpdateEventListener* GetListener(void) const;
177
178 private:
179         _ContentManagerImpl(const _ContentManagerImpl& rhs);
180         ContentId SaveDataToDatabase(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData) const;
181         result UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const;
182         result MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData, int systemType, void* pMetadata) const;
183         bool VerifyMediaFilePathCompatibility(const Tizen::Base::String& contentPath, bool checkVersion) const;
184         bool VerifyHomeFilePathCompatibility(const Tizen::Base::String& contentPath) const;
185         _ContentManagerImpl& operator =(const _ContentManagerImpl& rhs);
186
187 private:
188         bool __isConnected;
189         IContentUpdateEventListener* __pListener;
190         friend class _ContentDownloadHandler;
191
192 };  // class _ContentManagerImpl
193
194 }}  // Tizen::Content
195
196 #endif  // _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_