Move check_item_exist
[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 <mm_file.h>
24 #include <media-util.h>
25 #include "media-svc.h"
26 #include "media-svc-util.h"
27
28 int cleanup_db(sqlite3 *handle, uid_t uid)
29 {
30         /* For scanner V2 */
31         return MS_MEDIA_ERR_NONE;
32 }
33
34 int insert_item_begin(int item_cnt, int with_noti, int from_pid)
35 {
36         return media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
37 }
38
39 int insert_item_end(uid_t uid)
40 {
41         return media_svc_insert_item_end(uid);
42 }
43
44 int insert_item(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
45 {
46         return media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, uid);
47 }
48
49 int set_all_storage_items_validity(const char *storage_id, int storage_type, int validity, uid_t uid)
50 {
51         return media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
52 }
53
54 int set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
55 {
56         return media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
57 }
58
59 int set_item_validity_begin(int item_cnt)
60 {
61         return media_svc_set_item_validity_begin(item_cnt);
62 }
63
64 int set_item_validity_end(uid_t uid)
65 {
66         return media_svc_set_item_validity_end(uid);
67 }
68
69 int set_item_validity(const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid)
70 {
71         return media_svc_set_item_validity(storage_id, file_path, validity, uid);
72 }
73
74 int delete_item(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
75 {
76         return media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
77 }
78
79 int delete_all_invalid_items_in_storage(sqlite3 *handle, const char *storage_id, int storage_type, uid_t uid)
80 {
81         return media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
82 }
83
84 int send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
85 {
86         return media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
87 }
88
89 int check_db(sqlite3 *handle, uid_t uid)
90 {
91         int ret = MS_MEDIA_ERR_NONE;
92         int user_version = -1;
93
94         ret = media_svc_get_user_version(handle, &user_version);
95         if (ret != MS_MEDIA_ERR_NONE)
96                 return ret;
97
98         if (user_version == 0)
99                 ret = media_svc_create_table(uid);
100         else
101                 ret = media_svc_check_db_upgrade(handle, user_version, uid);
102
103         return ret;
104 }
105
106 int update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid)
107 {
108         /* For scanner V2 */
109         return MS_MEDIA_ERR_NONE;
110 }
111
112 int get_uuid(char **uuid)
113 {
114         return media_svc_generate_uuid(uuid);
115 }
116
117 int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
118 {
119         return media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
120 }
121
122 int insert_storage(sqlite3 *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
123 {
124         return media_svc_insert_storage(handle, storage_id, storage_path, storage_type, uid);
125 }
126
127 int update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
128 {
129         return media_svc_update_storage(handle, storage_id, storage_path, uid);
130 }
131
132 int set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid)
133 {
134         return media_svc_set_storage_validity(handle, storage_id, validity, uid);
135 }
136
137 int set_all_storage_validity(sqlite3 *handle, int validity, uid_t uid)
138 {
139         return media_svc_set_storage_validity(handle, NULL, validity, uid);
140 }
141
142 int get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
143 {
144         return media_svc_get_storage_id(handle, path, storage_id, uid);
145 }
146
147 int set_storage_scan_status(sqlite3 *handle, const char *storage_id, int status, uid_t uid)
148 {
149         /* For scanner V2 */
150         return MS_MEDIA_ERR_NONE;
151 }
152
153 int get_storage_list(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count)
154 {
155         return media_svc_get_storage_list(handle, storage_list, storage_id_list, count);
156 }
157
158 int update_item_begin(int item_cnt)
159 {
160         return media_svc_update_item_begin(item_cnt);
161 }
162
163 int update_item_end(uid_t uid)
164 {
165         return media_svc_update_item_end(uid);
166 }
167
168 int update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid)
169 {
170         return media_svc_update_item_meta(file_path, storage_id, storage_type, uid);
171 }
172
173 int insert_item_scan(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
174 {
175         /* For scanner V2 */
176         return MS_MEDIA_ERR_NONE;
177 }
178
179 int get_extract_list(sqlite3* handle, const char* storage_id, int storage_type, int scan_type, const char* path, int burst, uid_t uid, void* array)
180 {
181         /* For scanner V2 */
182         return MS_MEDIA_ERR_NONE;
183 }
184
185 int update_one_extract_item(sqlite3* handle, const char* storage_id, int storage_type, void* data)
186 {
187         /* For scanner V2 */
188         return MS_MEDIA_ERR_NONE;
189 }
190
191 int query_do_update_list(sqlite3* handle)
192 {
193         /* For scanner V2 */
194         return MS_MEDIA_ERR_NONE;
195 }
196
197 int delete_all_invalid_items_in_folder(sqlite3 *handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
198 {
199         /* For scanner V2 */
200         return MS_MEDIA_ERR_NONE;
201 }
202
203 int delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid)
204 {
205         /* For scanner V2 */
206         return MS_MEDIA_ERR_NONE;
207 }
208
209 int insert_folder_begin(int item_cnt)
210 {
211         return media_svc_insert_folder_begin(item_cnt);
212 }
213
214 int insert_folder_end(uid_t uid)
215 {
216         return media_svc_insert_folder_end(uid);
217 }
218
219 int insert_folder(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
220 {
221         return media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
222 }
223
224 int delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid)
225 {
226         return media_svc_delete_invalid_folder(storage_id, storage_type, uid);
227 }
228
229 int set_folder_validity(sqlite3 *handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid)
230 {
231         return media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
232 }
233
234 int get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *status)
235 {
236         /* For scanner V2 */
237         return MS_MEDIA_ERR_NONE;
238 }
239
240 int set_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int status, uid_t uid)
241 {
242         /* For scanner V2 */
243         return MS_MEDIA_ERR_NONE;
244 }
245
246 int check_folder_modified(sqlite3 *handle, const char *path, const char *storage_id, bool *modified)
247 {
248         /* For scanner V2 */
249         return MS_MEDIA_ERR_NONE;
250 }
251
252 int get_null_scan_folder_list(sqlite3 *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
253 {
254         /* For scanner V2 */
255         return MS_MEDIA_ERR_NONE;
256 }
257
258 int change_validity_item_batch(sqlite3 *handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
259 {
260         /* For scanner V2 */
261         return MS_MEDIA_ERR_NONE;
262 }
263
264 int check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
265 {
266         return media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
267 }
268
269 int get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
270 {
271         return media_svc_get_folder_id(handle, storage_id, path, folder_id);
272 }
273
274 int get_media_type(const char *path, int *mediatype)
275 {
276         return media_svc_get_media_type(path, mediatype);
277 }