Remove wrapping struct
[platform/core/multimedia/libmedia-service.git] / plugin / media-content-plugin.c
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <string.h>
23 #include <sys/stat.h>
24 #include <mm_file.h>
25 #include <media-util.h>
26 #include "media-svc.h"
27 #include "media-svc-util.h"
28
29 int cleanup_db(sqlite3 *handle, uid_t uid)
30 {
31         return media_svc_cleanup_db(handle, uid);
32 }
33
34 int check_item_exist(sqlite3 *handle, const char *storage_id, const char *file_path, bool *modified)
35 {
36         int ret = MS_MEDIA_ERR_NONE;
37         *modified = TRUE;
38
39         time_t modified_time = 0;
40         unsigned long long file_size = 0;
41         struct stat st;
42
43         ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
44         if (ret == MS_MEDIA_ERR_NONE) {
45                 memset(&st, 0, sizeof(struct stat));
46                 if (stat(file_path, &st) == 0) {
47                         if ((st.st_mtime != modified_time) || (st.st_size != file_size))
48                                 *modified = TRUE;
49                         else
50                                 *modified = FALSE;
51                 }
52
53                 return ret;
54         }
55
56         return ret;
57 }
58
59 int insert_item_begin(int item_cnt, int with_noti, int from_pid)
60 {
61         return media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
62 }
63
64 int insert_item_end(uid_t uid)
65 {
66         return media_svc_insert_item_end(uid);
67 }
68
69 int insert_item(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
70 {
71         return media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, uid);
72 }
73
74 int set_all_storage_items_validity(const char *storage_id, int storage_type, int validity, uid_t uid)
75 {
76         return media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
77 }
78
79 int set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
80 {
81         return media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
82 }
83
84 int set_item_validity_begin(int item_cnt)
85 {
86         return media_svc_set_item_validity_begin(item_cnt);
87 }
88
89 int set_item_validity_end(uid_t uid)
90 {
91         return media_svc_set_item_validity_end(uid);
92 }
93
94 int set_item_validity(const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid)
95 {
96         return media_svc_set_item_validity(storage_id, file_path, validity, uid);
97 }
98
99 int delete_item(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
100 {
101         return media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
102 }
103
104 int delete_all_invalid_items_in_storage(sqlite3 *handle, const char *storage_id, int storage_type, uid_t uid)
105 {
106         return media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
107 }
108
109 int send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
110 {
111         return media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
112 }
113
114 int check_db(sqlite3 *handle, uid_t uid)
115 {
116         int ret = MS_MEDIA_ERR_NONE;
117         int user_version = -1;
118
119         ret = media_svc_get_user_version(handle, &user_version);
120         if (ret != MS_MEDIA_ERR_NONE)
121                 return ret;
122
123         if (user_version == 0)
124                 ret = media_svc_create_table(uid);
125         else
126                 ret = media_svc_check_db_upgrade(handle, user_version, uid);
127
128         return ret;
129 }
130
131 int update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid)
132 {
133         /* For scanner V2 */
134         return MS_MEDIA_ERR_NONE;
135 }
136
137 int get_uuid(char **uuid)
138 {
139         return media_svc_generate_uuid(uuid);
140 }
141
142 int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
143 {
144         return media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
145 }
146
147 int insert_storage(sqlite3 *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
148 {
149         return media_svc_insert_storage(handle, storage_id, storage_path, storage_type, uid);
150 }
151
152 int update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
153 {
154         return media_svc_update_storage(handle, storage_id, storage_path, uid);
155 }
156
157 int set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid)
158 {
159         return media_svc_set_storage_validity(handle, storage_id, validity, uid);
160 }
161
162 int set_all_storage_validity(sqlite3 *handle, int validity, uid_t uid)
163 {
164         return media_svc_set_storage_validity(handle, NULL, validity, uid);
165 }
166
167 int get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
168 {
169         return media_svc_get_storage_id(handle, path, storage_id, uid);
170 }
171
172 int set_storage_scan_status(sqlite3 *handle, const char *storage_id, int status, uid_t uid)
173 {
174         /* For scanner V2 */
175         return MS_MEDIA_ERR_NONE;
176 }
177
178 int get_storage_list(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count)
179 {
180         return media_svc_get_storage_list(handle, storage_list, storage_id_list, count);
181 }
182
183 int update_item_begin(int item_cnt)
184 {
185         return media_svc_update_item_begin(item_cnt);
186 }
187
188 int update_item_end(uid_t uid)
189 {
190         return media_svc_update_item_end(uid);
191 }
192
193 int update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid)
194 {
195         return media_svc_update_item_meta(file_path, storage_id, storage_type, uid);
196 }
197
198 int insert_item_scan(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
199 {
200         /* For scanner V2 */
201         return MS_MEDIA_ERR_NONE;
202 }
203
204 int get_extract_list(sqlite3* handle, const char* storage_id, int storage_type, int scan_type, const char* path, uid_t uid, void* array)
205 {
206         /* For scanner V2 */
207         return MS_MEDIA_ERR_NONE;
208 }
209
210 int update_one_extract_item(sqlite3* handle, const char* storage_id, int storage_type, void* data)
211 {
212         /* For scanner V2 */
213         return MS_MEDIA_ERR_NONE;
214 }
215
216 int query_do_update_list(sqlite3* handle)
217 {
218         /* For scanner V2 */
219         return MS_MEDIA_ERR_NONE;
220 }
221
222 int delete_all_invalid_items_in_folder(sqlite3 *handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
223 {
224         /* For scanner V2 */
225         return MS_MEDIA_ERR_NONE;
226 }
227
228 int delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid)
229 {
230         /* For scanner V2 */
231         return MS_MEDIA_ERR_NONE;
232 }
233
234 int insert_folder_begin(int item_cnt)
235 {
236         return media_svc_insert_folder_begin(item_cnt);
237 }
238
239 int insert_folder_end(uid_t uid)
240 {
241         return media_svc_insert_folder_end(uid);
242 }
243
244 int insert_folder(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
245 {
246         return media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
247 }
248
249 int delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid)
250 {
251         return media_svc_delete_invalid_folder(storage_id, storage_type, uid);
252 }
253
254 int set_folder_validity(sqlite3 *handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid)
255 {
256         return media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
257 }
258
259 int get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *status)
260 {
261         /* For scanner V2 */
262         return MS_MEDIA_ERR_NONE;
263 }
264
265 int set_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int status, uid_t uid)
266 {
267         /* For scanner V2 */
268         return MS_MEDIA_ERR_NONE;
269 }
270
271 int check_folder_modified(sqlite3 *handle, const char *path, const char *storage_id, bool *modified)
272 {
273         /* For scanner V2 */
274         return MS_MEDIA_ERR_NONE;
275 }
276
277 int get_null_scan_folder_list(sqlite3 *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
278 {
279         /* For scanner V2 */
280         return MS_MEDIA_ERR_NONE;
281 }
282
283 int change_validity_item_batch(sqlite3 *handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
284 {
285         /* For scanner V2 */
286         return MS_MEDIA_ERR_NONE;
287 }
288
289 int check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
290 {
291         return media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
292 }
293
294 int get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
295 {
296         return media_svc_get_folder_id(handle, storage_id, path, folder_id);
297 }
298
299 int get_media_type(const char *path, int *mediatype)
300 {
301         return media_svc_get_media_type(path, mediatype);
302 }