merge wrt-plugins-tizen_0.2.0-2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Mediacontent / Mediacontent.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
18
19 #ifndef _PLATFORM_MEDIA_CONTENT_H_
20 #define _PLATFORM_MEDIA_CONTENT_H_
21
22 #include <list>
23 #include <ctime>
24 #include "API/Mediacontent/IMediacontent.h"
25 #include "API/Mediacontent/IEventFindFolder.h"
26 #include "API/Mediacontent/IEventFindMedia.h"
27 #include "API/Mediacontent/IEventUpdateMedia.h"
28 #include "API/Mediacontent/IEventUpdateMediaItems.h"
29
30
31 #include <API/Mediacontent/MediacontentImage.h>
32 #include <API/Mediacontent/MediacontentVideo.h>
33 #include <API/Mediacontent/MediacontentAudio.h>
34 #include <API/Mediacontent/MediacontentLyrics.h>
35
36
37 #include <db-util.h>
38
39 #define MEDIA_DB_PATH "/opt/dbspace/.media.db"
40 typedef struct _media_folder_s
41 {
42         char* folder_uuid;
43         char* folder_path;
44         char* folder_name;
45         int storage_type;       
46         time_t modified_date;
47 }folder_s;
48
49
50 using namespace TizenApis::Api::Mediacontent;
51
52
53 namespace TizenApis {
54 namespace Platform {
55 namespace Mediacontent {
56
57 class Mediacontent : public Api::Mediacontent::IMediacontent
58 {
59
60         public:
61         Mediacontent();
62         virtual ~Mediacontent();
63
64         protected:
65         virtual void OnRequestReceived(const IEventFindMediaPtr &ptr);
66         virtual void OnRequestReceived(const IEventFindFolderPtr &ptr);
67         virtual void OnRequestReceived(const IEventUpdateMediaPtr &ptr);
68         virtual void OnRequestReceived(const IEventBrowseFolderPtr &ptr);
69         virtual void OnRequestReceived(const IEventUpdateMediaItemsPtr &ptr);   
70
71         private:
72         void convertToPlatformFolder(folder_s &media_folder, MediacontentFolderPtr& newFolder);
73         void readImageFromDB(sqlite3_stmt* pStmt, MediacontentImage* newImage);
74         void readVideoFromDB(sqlite3_stmt* pStmt, MediacontentVideo* newVideo);
75         void readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAudio);
76         bool updateMediaToDB(MediacontentMediaPtr mediaPtr);
77         tm toDateTm(time_t date);
78                 
79         string makeQuerySortMode(SortModeArrayPtr attr);
80
81         private:
82         sqlite3 *hDBCt;
83         int db_connnect_count;
84
85 };
86
87
88 }
89 }
90 }
91
92 #endif /* _PLATFORM_MEDIA_CONTENT_H_ */