ad1b854235c70a960987a0bdeac0717067b3672d
[framework/web/wrt-plugins-tizen.git] / src / Content / ContentManager.h
1 //
2 // Tizen Web Device API
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
19  
20 #ifndef _PLATFORM_MEDIA_CONTENT_MANAGER_H_
21 #define _PLATFORM_MEDIA_CONTENT_MANAGER_H_
22
23 #include <vector>
24 #include <list>
25 #include <dpl/mutex.h>
26 #include "IContentManager.h"
27
28 #include <ctime>
29 #include "IEventGetDirectories.h"
30 #include "IEventUpdate.h"
31 #include "IEventUpdateBatch.h"
32 #include "ContentSearchVisitor.h"
33
34 #include "ContentImage.h"
35 #include "ContentVideo.h"
36 #include "ContentAudio.h"
37 #include "AudioLyrics.h"
38
39 #include <media_content.h>
40 #include <metadata_extractor.h>
41
42 #define MEDIA_DEBUG 0
43 #define TAG_DELIMETER '/'  //After reviewing the ID3v2.3 spec the delimiter is a "/" for multiple entries.
44
45 namespace DeviceAPI {
46 namespace Content {
47
48 class MediacontentManager : public IMediacontentManager
49 {
50         public:
51         MediacontentManager();
52         virtual ~MediacontentManager();
53
54         static void readCommonDataFromMediaInfo(media_info_h info, MediacontentMedia* newMedia);
55         static void readImageFromMediaInfo( media_info_h info, MediacontentImage* newImage);
56         static void readVideoFromMediaInfo( media_info_h info, MediacontentVideo* newVideo);
57         static void readMusicFromMediaInfo( media_info_h info, MediacontentAudio* newAudio);
58
59         protected:
60         virtual void OnRequestReceived(const IEventFindFolderPtr &ptr);
61         virtual void OnRequestReceived(const IEventUpdateMediaPtr &ptr);
62         virtual void OnRequestReceived(const IEventBrowseFolderPtr &ptr);
63         virtual void OnRequestReceived(const IEventUpdateMediaItemsPtr &ptr);   
64
65         private:
66         static bool mediaFolderCallback(media_folder_h folder, void *user_data);        
67         static bool mediaItemCallback(media_info_h info, void* user_data);
68         static void convertToPlatformFolder(media_folder_h media_folder, MediacontentFolderPtr& newFolder);
69         bool updateMediaToDB(MediacontentMediaPtr mediaPtr);    
70         string makeQuerySortMode(SortModeArrayPtr attr, MediaSearchVisitor::QueryType value=MediaSearchVisitor::QUERY_FOLDER);
71         static tm toDateTm(time_t date);
72         media_content_orientation_e convertToOrientation(string orientation);
73
74         private:
75         static int m_instanceCount;
76         DPL::Mutex m_constructorMutex;
77
78 };
79
80 }
81 }
82
83 #endif /* _PLATFORM_MEDIA_CONTENT_MANAGER_H_ */