580ae0bd902b5bb36cad4f30c2ca9fee7b00a73c
[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  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <string.h>
21 #include <mm_file.h>
22 #include <media-util.h>
23 #include "media-svc.h"
24 #include "media-svc-util.h"
25
26 int insert_item_begin(bool with_noti, int from_pid)
27 {
28         return media_svc_insert_item_begin(with_noti, from_pid);
29 }
30
31 int insert_item_end(uid_t uid)
32 {
33         return media_svc_insert_item_end(uid);
34 }
35
36 int insert_item(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
37 {
38         return media_svc_insert_item_bulk(handle, storage_id, file_path, uid);
39 }
40
41 int set_item_validity(const char *storage_id, const char *file_path, int validity, uid_t uid)
42 {
43         return media_svc_set_item_validity(file_path, validity, uid);
44 }
45
46 int send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid)
47 {
48         return media_svc_send_dir_update_noti(dir_path, folder_id, (media_item_update_type_e)update_type, pid);
49 }
50
51 int check_db(sqlite3 *handle, uid_t uid)
52 {
53         int ret = MS_MEDIA_ERR_NONE;
54         bool exist = false;
55
56         ret = media_svc_check_table_exist(handle, &exist);
57         if (ret != MS_MEDIA_ERR_NONE)
58                 return ret;
59
60         if (!exist)
61                 ret = media_svc_create_table(uid);
62
63         return ret;
64 }
65
66 int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
67 {
68         return media_svc_check_storage(handle, storage_id, storage_path, validity);
69 }
70
71 int insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
72 {
73         return media_svc_insert_storage(handle, storage_id, storage_path, uid);
74 }
75
76 int update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
77 {
78         return media_svc_update_storage(handle, storage_id, storage_path, uid);
79 }
80
81 int set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid)
82 {
83         return media_svc_set_storage_validity(storage_id, validity, uid);
84 }
85
86 int set_all_storage_validity(sqlite3 *handle, int validity, uid_t uid)
87 {
88         return media_svc_set_storage_validity(NULL, validity, uid);
89 }
90
91 int get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
92 {
93         return media_svc_get_storage_id(handle, path, storage_id, uid);
94 }
95
96 int insert_folder(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
97 {
98         return media_svc_insert_folder(handle, storage_id, file_path, uid);
99 }
100
101 int set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
102 {
103         return media_svc_set_folder_validity(start_path, validity, is_recursive, uid);
104 }
105
106 int check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
107 {
108         return media_svc_check_folder_exist_by_path(handle, folder_path);
109 }
110
111 int get_media_type(const char *path, int *mediatype)
112 {
113         return media_svc_get_media_type(path, mediatype);
114 }
115
116 int refresh_item(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
117 {
118         return media_svc_refresh_item(handle, true, storage_id, path, uid);
119 }