Remove request_id
[platform/core/api/media-content.git] / src / media_storage.c
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 #ifdef _USE_TVPD_MODE
19 #include <media_info_private.h>
20
21 int media_storage_get_scan_status(const char *storage_uuid, media_storage_scan_status_e *scan_status)
22 {
23         int ret = MEDIA_CONTENT_ERROR_NONE;
24         media_svc_scan_status_type_e status = MEDIA_STORAGE_SCAN_NONE;
25
26         content_retip_if_fail(STRING_VALID(storage_uuid));
27         content_retip_if_fail(scan_status);
28
29         ret = media_svc_get_storage_scan_status(_content_get_db_handle(), storage_uuid, &status);
30         if (ret != MS_MEDIA_ERR_NONE) {
31                 content_error("media_svc_get_storage_scan_status failed");
32                 return _content_error_capi(ret);
33         }
34
35         *scan_status = status;
36
37         return ret;
38 }
39
40 int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data)
41 {
42         int ret = MEDIA_CONTENT_ERROR_NONE;
43
44         content_retip_if_fail(callback);
45         g_mutex_lock(_content_get_db_mutex());
46         ret = _media_db_get_storage(filter, callback, user_data);
47         g_mutex_unlock(_content_get_db_mutex());
48
49         return ret;
50 }
51
52 int media_storage_destroy(media_storage_h storage)
53 {
54         media_storage_s *_storage = (media_storage_s*)storage;
55
56         content_retip_if_fail(storage);
57
58         g_free(_storage->storage_id);
59         g_free(_storage->storage_path);
60         g_free(_storage);
61
62         return MEDIA_CONTENT_ERROR_NONE;
63 }
64
65 int media_storage_clone(media_storage_h *dst, media_storage_h src)
66 {
67         media_storage_s *_src = (media_storage_s*)src;
68
69         content_retip_if_fail(dst);
70         content_retip_if_fail(src);
71
72         media_storage_s *_dst = g_new0(media_storage_s, 1);
73
74         _dst->storage_id = g_strdup(_src->storage_id);
75         _dst->storage_path = g_strdup(_src->storage_path);
76
77         *dst = (media_storage_h)_dst;
78
79         return MEDIA_CONTENT_ERROR_NONE;
80 }
81
82 int media_storage_get_id(media_storage_h storage, char **storage_id)
83 {
84         media_storage_s *_storage = (media_storage_s*)storage;
85
86         content_retip_if_fail(storage);
87         content_retip_if_fail(storage_id);
88
89         *storage_id = g_strdup(_storage->storage_id);
90
91         return MEDIA_CONTENT_ERROR_NONE;
92 }
93
94 int media_storage_get_path(media_storage_h storage, char **storage_path)
95 {
96         media_storage_s *_storage = (media_storage_s*)storage;
97
98         content_retip_if_fail(storage);
99         content_retip_if_fail(storage_path);
100
101         *storage_path = g_strdup(_storage->storage_path);
102
103         return MEDIA_CONTENT_ERROR_NONE;
104 }
105 #endif